I changed to flashing via usb for this reason, its all done in 20 seconds and with the CLI its simple.
download the bin file by clicking the little cloud next to the filename (it saves and compiles for you)
open a cmd prompt and go to where you saved the file
put the core in DFU mode
type spark flash --usb firmware.bin
then if you make a change to the firmware in build, re-download overwriting the old file, put the core in DFU, push up in the cmd prompt and hit enter⦠takes 3 seconds to do then 20 seconds to flash⦠it takes longer for the core to re-connect to the cloud than to update it!
For some things like my doorbell i still have to do OTA flashes, but if the core is next to me USB is the way to go.
Sorry about that, the longer flash time might be our fault. We increased the chunk size during OTA, but we got reports of problems, so we reverted it back. Iām guessing you got the speed boost while it was deployed, and then are back at normal speeds now. Weāre still working on speeding things up, and firmware compiled with the latest version should use the bigger chunk size.
thanks for the info @Dave, Iām not sure what was going on but itās now back to flashing quicker again
I have now found what was causing the problem with the spark function that Iām using to write the delays to the core.
If I have a delay that is more then 999ms then the core will time out ( gives me a few flashes of the cyan led just before that- relevant ?)
I think I have enough room assigned in the array and buffer being used to store the sent string of delays, so what could be going on here ?
I have changed this line:
if(now>=1000) // max time *update*
just in case, but as this is part of the playback and not the delay saving I would have thought it would make no difference to saving the string.
Has anyone got any ideas why my code (post 18 above) fails if I try to write a delay larger than 999ms ?
Cheers,
mala
I think you will do better if you treat Spark.fuction()'s similar to interrupt handlers and use the Spark.function() to set a flag for some action to be taken the next time your loop() code runs. So that means having a flag like runPlayback that is set in the Spark.function and then in loop you would have if (runPlayback) { ... }. Having the Spark function block for a long time (1 sec) might be causing you trouble.
Hi @bko
Thanks for the reply, what you say makes sense to me in terms of tidying up my code and making things more effecient.
but could this be the cause of this particular problem ? when everything is fine with the core saving the sent number 999 but not a 1000 ?
I will though take your advice and rework my code as suggested and see if it helps !
Thanks
mala
so before I followed your suggestion I have been stripping out all the code until I got down to the last part causing the problem, this part is
char delayVariable [100]; //array to store sent string of delays
void setup()
{
Spark.function("setdelays", saveDelays);
}
int saveDelays(String command)
{
command.toCharArray(delayVariable,100);
return 1;
}
the command sent from terminal is the 16 delays comma separated,as below(token&ID removed)
the above works fine until I change one of those 999 to 1000, then it will just time out.
The only thing I can think of is itās something to do with command.CharArray ???
I had changed the array size from 85 to 100 wondering if that would make any differenceā¦but no.
It looks like you are crossing through 64 characters for your function call string and that is the limit. Your string with all 9's has 63 characters now, if you add any character, you will have too many.
can you pass the index of the array and the value in, instead of just passing 16 values? so you would pass ā0,999ā and then ā1,999ā, etc. the down side is you would have to call the function 16 times, but you shouldnāt violate the 64 character limit.
alternatively, you could make it so that you could pass multiple āindex,valueā pairs to cut down on the function calls. so set up the parser to take multiple key/value pairs and then you could call it with something like ā0,999,3,995,8,500ā or whatever, only changing the values that you need to.
@Dave Thanks, Iām not using the delays like that but I do appreciate the test
I have done a test setting only 14 delayed outputs and found that using a delay larger than 999 in my code was not a problem.
The problem is as @bko pointed out, that Iām violating the 64 character limit in the sent string for the variable.
@eely22 thanks for the suggestions I will have a think and experiment with this.
To be honest this problem combined with the other topic i posted here https://community.spark.io/t/need-more-inputs-solved/6807/11
Is making me think I should just maybe pare the number of outputs down to 14 and keep things simple.
As I still have to figure out all the GUI side of stuff I want to build as well.
Ok, well I drew up a quick example to do this, if you wanted to do it this way. From the UI, it should be pretty easy, just call the function for the delays that changed when they change. I briefly tested it out (on my SparkLE even!) and it is working:
#define MAX_NUM_DELAYS 8
int delays[MAX_NUM_DELAYS];
int saveDelays (String command);
void setup ()
{
Spark.function ("setdelays", saveDelays);
}
int saveDelays (String command)
{
char buffer[command.length()];
command.toCharArray(buffer, command.length());
int index, value;
bool save = false;
char* token = strtok (buffer,",");
while (token != NULL)
{
if (save) {
value = atoi(token);
if (index < 0 ||index >= MAX_NUM_DELAYS) {
//error stuff happens here, index is out of bounds
} else {
delays[index] = value;
}
} else {
index = atoi(token);
}
save = !save;
token = strtok (NULL, ",");
}
}
void loop() {
}
Thanks! @eely22
Iām already several beers into a Friday night so will have a look at this tomorrow.
I am very interested in your SparkLE by the way and itās a great name!
But also as I have no experience of html,java, web type things!
I have rather a general question to do with the GUI Iād like to build, rather than have 12 to 16 individual buttons for each output with a field next to each one for the delay value I was wondering if there is any way I could make an interface similar to this: (User data field from a 3D program I use)
Each point on the spline representing an output and the Y axis being the delay, the user can click and drag a point up/down to set delay time(with exact time being shown in the little"Delay" field.
Now of course Iām light years away from being able to build this GUI, but I would like to know if anyone can think of a an app,plug in, method or whatever that may be able to create this kind of interface, that could be hosted on a web page.
This to me is a more interesting way to interact with the application I hope to build and if it could be done, then perhaps even preset āspline waves/shapesā could applied to outputs.