diff --git a/.gitignore b/.gitignore index 2390238e37b75460197442905e80872de658599c..15410bfc37db969ae5d3894d46818aff67392a44 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ Desktop.ini # build products blink1-tool +blink1-tiny-server +builds \ No newline at end of file diff --git a/README-MakingReleases.md b/README-MakingReleases.md index 2f031dce8c54cb96e3f4a918d6614ac8b5f3da14..675122c080ad525e5d4668d2214f5b7c18b26391 100644 --- a/README-MakingReleases.md +++ b/README-MakingReleases.md @@ -25,7 +25,8 @@ Assumptions General Process --------------- -1. `cd blink1/commmandline` +1. `cd blink1-tool` +2. git tag release 2. Build code with `make clean && make` 3. Package up zipfile with `make package` 4. Copy zip package to and test on separate test systems diff --git a/blink1-lib.c b/blink1-lib.c index a76b1723e74fa558141a762c8a7e0b213c6d28d5..a8a1ffacb8224a329795e3b7fd34050b34df45f5 100644 --- a/blink1-lib.c +++ b/blink1-lib.c @@ -479,7 +479,7 @@ int blink1_savePattern( blink1_device *dev ) return rc; } -// only for mk2a devices (fw val '204') +// only for devcies with fw val 204+ int blink1_setLEDN( blink1_device* dev, uint8_t ledn) { uint8_t buf[blink1_buf_size]; @@ -491,7 +491,41 @@ int blink1_setLEDN( blink1_device* dev, uint8_t ledn) return rc; } -// +// only for devices with fw val 206+ or mk3 +int blink1_getStartupParams( blink1_device* dev, uint8_t* bootmode, + uint8_t* playstart, uint8_t* playend, uint8_t* playcount) +{ + uint8_t buf[blink1_buf_size] = { blink1_report_id, 'b', 0,0,0, 0,0, 0 }; + + int rc = blink1_read(dev, buf, sizeof(buf) ); + if( rc != -1 ) { + *bootmode = buf[2]; + *playstart = buf[3]; + *playend = buf[4]; + *playcount = buf[5]; + } + return rc; +} + +// only for devices with fw val 206+ or mk3 +// FIXME: make 'params' a struct +int blink1_setStartupParams( blink1_device* dev, uint8_t bootmode, + uint8_t playstart, uint8_t playend, uint8_t playcount) +{ + uint8_t buf[blink1_buf_size]; + buf[0] = blink1_report_id; + buf[1] = 'B'; + buf[2] = bootmode; // (0=normal, 1=play, 2=off) + buf[3] = playstart; + buf[4] = playend; + buf[5] = playcount; + buf[6] = 0; // unused1 + buf[7] = 0; // unused2 + int rc = blink1_write(dev, buf, sizeof(buf) ); + return rc; +} + +// only for mk3 int blink1_writeNote( blink1_device* dev, uint8_t noteid, const uint8_t* notebuf) { uint8_t buf[blink1_report2_size] = { blink1_report2_id, 'F', noteid }; @@ -517,7 +551,7 @@ int blink1_readNote( blink1_device* dev, uint8_t noteid, uint8_t** notebuf) return rc; } -// +// only for mk3 int blink1_goBootloader( blink1_device* dev ) { uint8_t buf[blink1_report_size] = { blink1_report_id, 'G', 'o','B','o','o','t',0 }; diff --git a/blink1-lib.h b/blink1-lib.h index 54ea64b3c0d34d446f9bcdd6e1550f05dc7e4f2f..704a72d549038c1b0a013d01ed457041b3eb646e 100644 --- a/blink1-lib.h +++ b/blink1-lib.h @@ -303,7 +303,7 @@ int blink1_readPatternLine(blink1_device *dev, uint16_t* fadeMillis, uint8_t pos); /** * Read a color pattern line to blink1. - * @note ledn param only works on unreleased mk2a devices + * @note ledn param only works on fw204+ devices * @param dev blink1 device to command * @param fadeMillis pointer to milliseconds to fade to RGB color * @return -1 on error, 0 on success @@ -323,10 +323,23 @@ int blink1_savePattern(blink1_device *dev); /** * Sets 'ledn' parameter for blink1_savePatternLine() - * @note only for unreleased mk2a devices + * @note only works on fw 204+ devices */ int blink1_setLEDN( blink1_device* dev, uint8_t ledn); +/** + * @note only for devices with fw val 206+ or mk3 + */ +int blink1_getStartupParams( blink1_device* dev, uint8_t* bootmode, + uint8_t* playstart, uint8_t* playend, uint8_t* playcount); + +/** + * @note only for devices with fw val 206+ or mk3 + * FIXME: make 'params' a struct + */ +int blink1_setStartupParams( blink1_device* dev, uint8_t bootmode, + uint8_t playstart, uint8_t playend, uint8_t playcount); + /** * Tell blink(1) to reset into bootloader. * mk3 devices only diff --git a/blink1-tool.c b/blink1-tool.c index 7588c65b479f657fdf810defdf7e932c70ecc3fe..035fe7e5d3fa1694394c68ce78d7be5e58026f91 100644 --- a/blink1-tool.c +++ b/blink1-tool.c @@ -29,6 +29,9 @@ #include "blink1-lib.h" +// set to 1 to enable mk3 features +#define ENABLE_MK3 1 + #ifndef BLINK1_VERSION #define BLINK1_VERSION "v0.0" #endif @@ -102,6 +105,9 @@ static void usage(char *myName) " Nerd functions: \n" " --fwversion Display blink(1) firmware version \n" " --version Display blink1-tool version info \n" +#if 0 +" --gobootload Enable bootloader (mk3 only)\n" +#endif "and [options] are: \n" " -d dNums --id all|deviceIds Use these blink(1) ids (from --list) \n" " -g -nogamma Disable autogamma correction\n" @@ -127,10 +133,16 @@ static void usage(char *myName) " blink1-tool -m 500 --rgb 112233 --setpattline 1 \n" " # Erase all lines of the color pattern and save to flash \n" " blink1-tool --clearpattern ; blink1-tool --savepattern \n" -#if 0 -"User notes (mk3 only)\n" +#if ENABLE_MK3 == 1 +"\n" +"User notes (mk3 feature):\n" " blink1-tool --writenote 1 -n 'hello there' \n" " blink1-tool --readnote 1 \n" +"\n" +"Setting startup params (mk3 feature):\n" +" blink1-tool --setstartup 1,5,7,10 # enable, play 5-7 loop 10 times\n" +" blink1-tool --savepattern # must do this to save to flash \n" +"" #endif "\n" "Notes \n" @@ -180,6 +192,8 @@ enum { CMD_READPATTERN, CMD_WRITENOTE, CMD_READNOTE, + CMD_SETSTARTUP, + CMD_GETSTARTUP, CMD_GOBOOTLOAD, CMD_SETRGB, CMD_TESTTEST @@ -290,6 +304,8 @@ int main(int argc, char** argv) {"writepattern", required_argument, &cmd, CMD_WRITEPATTERN }, {"readpattern", no_argument, &cmd, CMD_READPATTERN }, {"clearpattern", no_argument, &cmd, CMD_CLEARPATTERN }, + {"setstartup", required_argument, &cmd, CMD_SETSTARTUP}, + {"getstartup", no_argument, &cmd, CMD_GETSTARTUP}, {"testtest", no_argument, &cmd, CMD_TESTTEST }, {"reportid", required_argument, 0, 'i' }, {"writenote", required_argument, &cmd, CMD_WRITENOTE}, @@ -320,6 +336,7 @@ int main(int argc, char** argv) case CMD_GETPATTLINE: case CMD_PLAY: case CMD_SERVERDOWN: + case CMD_SETSTARTUP: // FIXME hexread(cmdbuf, optarg, sizeof(cmdbuf)); // cmd w/ hexlist arg break; case CMD_BLINK: @@ -610,7 +627,7 @@ int main(int argc, char** argv) uint8_t b = rgbbuf.b; uint8_t p = cmdbuf[0]; msg("saving rgb: 0x%2.2x,0x%2.2x,0x%2.2x @ %d, ms:%d\n",r,g,b,p,millis); - if( ledn>=0 ) { // NOTE: only works for unreleased mk2a + if( ledn>=0 ) { // NOTE: only works for fw 204+ devices blink1_setLEDN(dev, ledn); // FIXME: doesn't check return code } rc = blink1_writePatternLine(dev, millis, r,g,b, p ); @@ -822,6 +839,29 @@ int main(int argc, char** argv) sprintf(str,"%s}",str); msg("%s\n",str); } + else if( cmd == CMD_SETSTARTUP ) { + msg("set startup params:"); + uint8_t bootmode = cmdbuf[0]; + uint8_t playstart = cmdbuf[1]; + uint8_t playend = cmdbuf[2]; + uint8_t playcount = cmdbuf[3]; + msg(" bootmode: %d, play start/end/count: %d/%d/%d\n", + bootmode, playstart,playend,playcount); + rc = blink1_setStartupParams(dev, bootmode, playstart, playend, playcount); + if( rc == -1 ) { + msg("error: %d\n",rc); + } + } + else if( cmd == CMD_GETSTARTUP ) { + msg("get startup params:"); + uint8_t bootmode; + uint8_t playstart; + uint8_t playend; + uint8_t playcount; + rc = blink1_getStartupParams(dev, &bootmode, &playstart, &playend, &playcount); + msg(" bootmode: %d, play start/end/count: %d/%d/%d\n", + bootmode, playstart,playend,playcount); + } else if( cmd == CMD_WRITENOTE ) { uint8_t noteid = arg; uint8_t* notebuf = (uint8_t*)argbuf;