diff --git a/lighthub/flashstream.cpp b/lighthub/flashstream.cpp index ee79226..06fef8f 100644 --- a/lighthub/flashstream.cpp +++ b/lighthub/flashstream.cpp @@ -39,6 +39,8 @@ extern NRFFlashStorage EEPROM; #if defined(__SAM3X8E__) DueFlashStorage EEPROM; + static char samBuffer[64]; + short samBufferPos = 0; #endif #ifdef NRF5 @@ -129,6 +131,10 @@ NRFFlashStorage EEPROM; int flashStream::open(short fileNum, char mode) { + #if defined(__SAM3X8E__) + samBufferPos = 0; + #endif + switch (fileNum) { case FN_CONFIG_JSON: pos = 0; @@ -138,6 +144,7 @@ NRFFlashStorage EEPROM; #ifdef OTA contentType = HTTP_TEXT_JSON; #endif + openmode = mode; return 1; case FN_CONFIG_BIN: @@ -148,6 +155,7 @@ NRFFlashStorage EEPROM; #ifdef OTA contentType = HTTP_OCTET_STREAM; #endif + openmode = mode; return 1; default: @@ -171,7 +179,13 @@ NRFFlashStorage EEPROM; }; unsigned int flashStream::seek(unsigned int _pos) - { pos=min(_pos, streamSize); + { + + #if defined(__SAM3X8E__) + if (samBufferPos) flush(); + #endif + + pos=min(_pos, streamSize); //debugSerial<1) #else sysConfStream.open(FN_CONFIG_JSON,'w'); #endif - +/* #if defined(__SAM3X8E__) long configBufSize = min(MAX_JSON_CONF_SIZE,freeRam()-1024); debugSerial<<"Allocate "<1) return 500; } infoSerial<itemArg || (item->itemArg->type != aJson_Array) || aJson.getArraySize(item->itemArg)<1) @@ -28,8 +29,8 @@ bool out_pid::getConfig() errorSerial<type == aJson_Float) outMax=param->valuefloat; - else if (param->type == aJson_Int) outMax=param->valueint; + if (param->type == aJson_Float) {outMax=param->valuefloat;limits=true;} + else if (param->type == aJson_Int) {outMax=param->valueint;limits=true;} case 7: //kP,kI,kD,dT alarmTO, alarmVal, outMin param = aJson.getArrayItem(kPIDObj, 6); - if (param->type == aJson_Float) outMin=param->valuefloat; - else if (param->type == aJson_Int) outMin=param->valueint; + if (param->type == aJson_Float) {outMin=param->valuefloat;limits=true;} + else if (param->type == aJson_Int) {outMin=param->valueint;limits=true;} case 6: //kP,kI,kD,dT, alarmTO, alarmVal case 5: //kP,kI,kD,dT, alarmTO @@ -99,7 +100,7 @@ bool out_pid::getConfig() {store->pid= new PID (&store->input, &store->output, &store->setpoint, kP, kI, kD, direction); if (!store->pid) return false; store->pid->SetMode(AUTOMATIC); - //store->pid->SetOutputLimits(outMin,outMax); + if (limits) store->pid->SetOutputLimits(outMin,outMax); store->pid->SetSampleTime(dT*1000.0); return true;} else errorSerial<