- if (p[3].length > 16*4 || p[4].length > 16*4 || p[5].length > 16*4) {
- print ("pattern too long!\n");
- return false;
- }
+ if (p[3].length > 16*4 || p[4].length > 16*4 || p[5].length > 16*4)
+ throw new LedPatternError.INVALID_PATTERN ("%s engine pattern too long!".printf (name));
+
+ if (p[3].length % 4 != 0 || p[4].length % 4 != 0 || p[5].length % 4 != 0)
+ throw new LedPatternError.INVALID_PATTERN ("%s engine pattern not an even number of bytes!".printf (name));