void SerialUI::exit(bool terminate_gui) { #ifdef SUI_ENABLE_MODES if (mode() == SUIMode_Program) { if (terminate_gui) println_P(terminate_gui_prog); println_P(end_of_tx_str); // ensure we always restart in "user" mode... setMode(SUIMode_User); } else #endif { returnMessage(goodbye); } user_present = false; user_presence_last_interaction_ms = 0; // go back to top level menu, in case we re-enter SUI later... current_menu = &top_lev_menu; }
//------------------------------------------------------------------------------ static void testResult(bool b, uint8_t n) { while (n++ < 60) testOut->write(' '); if (b) { println_P(testOut, PSTR("..ok")); } else { println_P(testOut, PSTR("FAIL")); failCount++; } testCount++; }
void SerialUI::showEnterDataPrompt() { #ifdef SUI_ENABLE_MODES if (mode() == SUIMode_Program) { println_P(moredata_prompt_prog_str); println_P(end_of_tx_str); return; } #endif print_P(moredata_prompt_str); }
//------------------------------------------------------------------------------ void testEnd() { testOut->println(); println_P(testOut, PSTR("Compiled: " __DATE__ " " __TIME__)); print_P(testOut, PSTR("FreeRam: ")); testOut->println(FreeRam()); print_P(testOut, PSTR("Test count: ")); testOut->println(testCount); print_P(testOut, PSTR("Fail count: ")); testOut->println(failCount); }
void SerialUI::showPrompt() { #ifdef SUI_SERIALUI_SHOW_PROMPT_SUBMENU_NAME if (current_menu->parent()) { current_menu->showName(); } #endif print_P(prompt_str); #ifdef SUI_ENABLE_MODES if (mode() == SUIMode_Program) { println(' '); println_P(end_of_tx_str); // return; } #endif }
/** %Print a string in flash memory to Serial followed by a CR/LF. * * \param[in] str Pointer to string stored in flash memory. */ void SdFatUtil::SerialPrintln_P(PGM_P str) { println_P( str); }
/** %Print a string in flash memory to Serial followed by a CR/LF. * * \param[in] str Pointer to string stored in flash memory. */ void SdFatUtil::SerialPrintln_P(PGM_P str) { println_P(SdFat::stdOut(), str); }
void SerialUI::debug_P(PGM_P debugmesg_p) { print_P(PSTR("DEBUG: ")); println_P(debugmesg_p); }
size_t SerialUI::showEnterStreamPromptAndReceive(char * bufferToUse, uint8_t bufferSize, streamInputCallback callback, streamInputStartCallback startupCallback, streamInputEndCallback completedCallback) { #ifdef SUI_ENABLE_MODES if (mode() == SUIMode_Program) { println_P(moredata_prompt_prog_stream); println_P(end_of_tx_str); } else { #endif print_P(moredata_prompt_stream); #ifdef SUI_ENABLE_MODES } #endif stream_expected_size = this->parseInt(); if (stream_expected_size < 1) return 0; bool doPipedata = true; // if this is true, we'll send the data over to the callback // but no matter what, we'll need to consume it. if (startupCallback) { doPipedata = startupCallback(stream_expected_size); } stream_cur_count = 0; // dump the terminator while (this->available() && (this->peek() == '\r' || this->peek() == '\n')) { this->read(); } while (stream_cur_count < stream_expected_size) { uint8_t lenToRead = (stream_expected_size - stream_cur_count) > bufferSize ? bufferSize : (stream_expected_size - stream_cur_count); size_t lenRead = this->readBytes(bufferToUse, lenToRead); if (! lenRead) { // looks like we timed out... return stream_cur_count; } if (doPipedata) callback(bufferToUse, lenRead, stream_cur_count, stream_expected_size); stream_cur_count += lenRead; } if (! doPipedata) return 0; // we just flushed the data... if (completedCallback) completedCallback(stream_cur_count); return stream_cur_count; }
int TwitPic::upload(const char *message, uint32_t imageLength, void (*imageTransfer)(Client *client), bool post) { int ret = -1; DEBUG_PRINT("connecting..."); if (client.connect()) { DEBUG_PRINTLN("ok\r\npost image"); // HTTP Request if(post){ println_P( PSTR("POST " TWITPIC_UPLADO_AND_POST_API_URL " HTTP/1.0") ); }else{ println_P( PSTR("POST " TWITPIC_UPLADO_API_URL " HTTP/1.0") ); } // HTTP Headers println_P( PSTR("Content-Type: multipart/form-data; boundary=" BOUNDARY) ); print_P( PSTR("Content-Length: ") ); println(preCalcedContentLength + strlen(message) + imageLength); println(); // Post Parameter println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: form-data; name=\"key\"") ); println(); println_P( twitpic_api_key ); // Post Parameter println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: form-data; name=\"consumer_token\"") ); println(); println_P( consumer_key ); // Post Parameter println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: form-data; name=\"consumer_secret\"") ); println(); println_P( consumer_secret ); // Post Parameter println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: form-data; name=\"oauth_token\"") ); println(); println_P( access_token ); // Post Parameter println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: form-data; name=\"oauth_secret\"") ); println(); println_P( access_token_secret ); // Post Parameter println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: form-data; name=\"message\"") ); println(); println(message); // Image Data if(imageTransfer){ println_P( PSTR(HEADER) ); println_P( PSTR("Content-Disposition: file; name=\"media\"; filename=\"img0000.jpg\"") ); println_P( PSTR("Content-Type: image/jpeg") ); println_P( PSTR("Content-Transfer-Encoding: binary") ); println(); imageTransfer(&client); println(); } // Footer println_P( PSTR(FOOTER) ); println(); // Wait Response client.flush(); ret = waitResponses(); client.stop(); }else{ DEBUG_PRINTLN("fail"); } return ret; }