How (not) to write code for a small chip
The project has two main set of procedures for color control and commands execution. Loving encapsulation and separation of concerns, I built two structs with function pointers, to mimic objects:
typedef struct CYZ_CMD {
unsigned char rcv_cmd_buf[8]; unsigned char rcv_cmd_buf_cnt; unsigned char rcv_cmd_len; Cyz_rgb* cyz_rgb; void (*execute)(void* this, unsigned char* buf); void (*receive_one_byte)(void* this, unsigned char rcv);} Cyz_cmd;
cyz_cmd->execute(cyz_cmd, play);
Added some commands (only in svn head)
‘W’ Write script line
Script 0 can be modified and up to 10 lines added and executed. With some limitations:
- line duration is ignored
- script lines only support fade to rgb and go to rgb
- script is not persisted and will disappear at next power off
- script number is ignored, can only write script 0 (as in original blinkm)
After writing a script with ‘W’, it can be xecuted with ‘p’. Only applies to script 0
‘o’ Stop script
No limitations here
See the project page for details.
Matteo