Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF51_Vdd TextLCD BME280
Revision 6:6dd8c932bd56, committed 2019-12-19
- Comitter:
- kenjiArai
- Date:
- Thu Dec 19 07:27:50 2019 +0000
- Parent:
- 5:c953eac8e31d
- Commit message:
- updated each main.cpp
Changed in this revision
--- a/0_Blinky_LED/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/0_Blinky_LED/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -1,11 +1,11 @@ /* * Mbed Application program / Blinky * - * Copyright (c) 2018 Kenji Arai / JH1PJL + * Copyright (c) 2018,'19 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: April 10th, 2018 - * Revised: April 14th, 2018 + * Revised: December 19th, 2019 */ //#define EXAMPLE_0_BLINKY_LED @@ -24,8 +24,8 @@ // RAM ------------------------------------------------------------------------ // ROM / Constant data -------------------------------------------------------- -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; // Function prototypes -------------------------------------------------------- @@ -43,7 +43,7 @@ while(true) { my_led = !my_led; pc.printf("%8u\r\n", count++); - Thread::wait(1000); + ThisThread::sleep_for(1000); } }
--- a/1_Check_RTC/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/1_Check_RTC/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -1,11 +1,11 @@ /* * Mbed Application program / check RTC (Real Time Clock) * - * Copyright (c) 2017,'18 Kenji Arai / JH1PJL + * Copyright (c) 2017,'18,'19 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: August 11th, 2017 - * Revised: April 14th, 2018 + * Revised: December 19th, 2019 */ //#define EXAMPLE_1_CHECK_RTC @@ -18,18 +18,23 @@ // Definition ----------------------------------------------------------------- // Constructor ---------------------------------------------------------------- -DigitalIn userSW(BUTTON1); +DigitalIn userSW(BUTTON1, PullUp); DigitalOut myled(LED1); // Indicate the sampling period Serial pc(USBTX, USBRX); // RAM ------------------------------------------------------------------------ // ROM / Constant data -------------------------------------------------------- -char *const msg0 = "Is a time correct? If no, please hit any key. "; -char *const msg1 = "<Push USER SW then enter sleep mode> "; -char *const msg2 = "\r\nEnter Standby Mode, please push RESET to wake-up\r\n"; -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const msg0 = "Is a time correct? If no, please hit any key. "; +const char *const msg1 = "<Push USER SW then enter sleep mode> "; +const char *const msg2 = + "\r\nEntered Standby Mode, please make a RESET(Alt+b) for wake-up\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const caution0 = "TYBLE16 RTC have two problem.\r\n"; +const char *const caution1 = + "1) Not accurate enough due to Internal RC LFCLK\r\n"; +const char *const caution2 = "2) After RESET, time is also reset"; // Function prototypes -------------------------------------------------------- static void time_enter_mode(void); @@ -51,15 +56,18 @@ // Check TYBLE-16 configuration cpu_sys(); compile_condition(); - myled = !myled; - wait(1.0); + pc.puts(caution0); + pc.puts(caution1); + pc.puts(caution2); myled = !myled; - wait(1.0); - while(1) { + ThisThread::sleep_for(1000); + myled = !myled; + ThisThread::sleep_for(1000); + while(true) { seconds = time(NULL); strftime(buf, 50, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds)); pc.printf("[Time] %s", buf); - pc.printf(msg0); + pc.printf("%s", msg0); pc.printf("%s\r", msg1); wait_counter = 0; while (seconds == time(NULL)) { @@ -68,12 +76,11 @@ time_enter_mode(); } if (userSW == 0) { - pc.printf(msg2); - wait(1.0); + pc.printf("%s", msg2); myled = 0; - goto_standby(); + ThisThread::flags_wait_any(0); // no signal will come forever! } - wait(0.05); + ThisThread::sleep_for(50); if (++wait_counter > (2000 / 50)) { break; } @@ -93,7 +100,7 @@ char linebuf[64]; pc.printf("\r\nSet time into RTC\r\n"); - pc.printf(" e.g. >18 4 14 10 11 12 -> April 14th,'18, 10:11:12\r\n"); + pc.printf(" e.g. >19 12 19 10 11 12 -> December 19,'19, 10:11:12\r\n"); pc.printf(" If time is fine, just hit enter\r\n"); pc.putc('>'); ptr = linebuf; @@ -102,11 +109,6 @@ chk_and_set_time(ptr); } -void goto_standby(void) -{ - deepsleep(); // Not Standby Mode but Deep Sleep Mode -} - // Get key input data void get_line (char *buff, int len) { @@ -142,22 +144,22 @@ if (xatoi(&ptr, &p1)) { t.tm_year = (uint8_t)p1 + 100; - pc.printf("Year:%d ",p1); + pc.printf("Year:%d ", (int)p1); xatoi( &ptr, &p1 ); t.tm_mon = (uint8_t)p1 - 1; - pc.printf("Month:%d ",p1); + pc.printf("Month:%d ", (int)p1); xatoi( &ptr, &p1 ); t.tm_mday = (uint8_t)p1; - pc.printf("Day:%d ",p1); + pc.printf("Day:%d ", (int)p1); xatoi( &ptr, &p1 ); t.tm_hour = (uint8_t)p1; - pc.printf("Hour:%d ",p1); + pc.printf("Hour:%d ", (int)p1); xatoi( &ptr, &p1 ); t.tm_min = (uint8_t)p1; - pc.printf("Min:%d ",p1); + pc.printf("Min:%d ", (int)p1); xatoi( &ptr, &p1 ); t.tm_sec = (uint8_t)p1; - pc.printf("Sec: %d \r\n",p1); + pc.printf("Sec: %d \r\n", (int)p1); } else { return; }
--- a/2_EddyStoneBeacon/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/2_EddyStoneBeacon/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -21,7 +21,7 @@ * https://os.mbed.com/users/kenjiArai/ * * Started: Feburary 18th, 2018 - * Revised: April 14th, 2018 + * Revised: December 19th, 2019 * * Original: * nRF51822_SimpleControls @@ -39,7 +39,6 @@ #include "mbed.h" #include "TYBLE16_BASE.h" #include "BLE.h" -//#include "EddystoneService.h" #include "../Eddystone/EddystoneService.h" // Object --------------------------------------------------------------------- @@ -53,8 +52,8 @@ Gap::Address_t my_mac; // ROM / Constant data -------------------------------------------------------- -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; // Function prototypes -------------------------------------------------------- int8_t check_dice(void); @@ -140,7 +139,7 @@ pc.printf("This is wrong configuration!!\r\n"); while(true) { led = !led; - wait(0.2); + ThisThread::sleep_for(200); } } BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); @@ -152,7 +151,8 @@ led = 0; //pc.printf("line:%d\r\n", __LINE__); while (true) { - ble.waitForEvent(); + //ble.waitForEvent(); + ThisThread::flags_wait_any(0); // no signal will come forever! } }
--- a/3_Heart_Rate/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/3_Heart_Rate/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -14,7 +14,7 @@ * limitations under the License. */ /* - Modified by Kenji Arai, April 14th, 2018 + Modified by Kenji Arai, December 19th,2019 https://os.mbed.com/users/kenjiArai/ */ @@ -34,8 +34,8 @@ Serial pc(USBTX, USBRX); const static char DEVICE_NAME[] = "TYBLE16"; -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; static const uint16_t uuid16_list[] = { GattService::UUID_HEART_RATE_SERVICE,
--- a/4_RCBController/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/4_RCBController/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -5,6 +5,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * April 14th, 2018 run on TYBLE16 + * December 19th, 2019 * * Original: * BLE_RCBController2_Motor @@ -40,8 +41,8 @@ static const uint16_t RCBController_service_uuid = 0xFFF0; static const uint16_t RCBController_Characteristic_uuid = 0xFFF1; const char *deviceName = "Mbed-BLE"; -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; GattCharacteristic ControllerChar ( RCBController_Characteristic_uuid,RCBControllerPayload,10, 10, @@ -124,7 +125,7 @@ int main(void) { - DEBUG(opngmsg); + DEBUG("%s", opngmsg); DEBUG("\r\nInitialising the nRF51822\r\n"); // Check TYBLE-16 configuration cpu_sys();
--- a/5_SDCard/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/5_SDCard/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -26,8 +26,9 @@ // Constructor ---------------------------------------------------------------- DigitalOut led(LED1); DigitalIn user_sw(BUTTON1, PullUp); -Serial pc(USBTX, USBRX, 115200); -SDBlockDevice sd(D3, D2, D0, D1, 8000000); +Serial pc(USBTX, USBRX); +SDBlockDevice sd( D2, D1, A0, D0, 8000000); +//SDBlockDevice sd(D3, D2, D0, D1, 8000000); FATFileSystem fs("fs"); // RAM ------------------------------------------------------------------------
--- a/6_Thermo/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/6_Thermo/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -14,7 +14,7 @@ * limitations under the License. */ /* - Modified by Kenji Arai, April 14th, 2018 + Modified by Kenji Arai, December 19th, 2019 https://os.mbed.com/users/kenjiArai/ */ @@ -45,8 +45,8 @@ static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE}; -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; static float currentTemperature = 39.6f; static HealthThermometerService *thermometerServicePtr; @@ -176,7 +176,7 @@ lcd.puts(" by JH1PJL "); lcd.setCursor(TextLCD_Base::CurOff_BlkOff); lcd.setContrast(0x19); - wait(2.0f); + ThisThread::sleep_for(2000); #endif // Check TYBLE-16 configuration cpu_sys(); @@ -184,7 +184,7 @@ pc.printf("This is wrong configuration!!\r\n"); while(true) { led1 = !led1; - wait(0.2); + ThisThread::sleep_for(200); } } #if USE_LCD
--- a/9_Monitor/main.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/9_Monitor/main.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -21,7 +21,7 @@ * * Started: January 3rd, 2016 * Revised: Feburary 13th, 2016 - * Revised: April 14th, 2018 + * Revised: December 19th, 2019 */ //#define EXAMPLE_9_MONITOR @@ -61,8 +61,8 @@ // ROM / Constant data -------------------------------------------------------- const char *deviceName = "mbedMon"; -char *const opngmsg = - "\x1b[2J\x1b[H"__FILE__ "\r\n"__DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; +const char *const opngmsg = + "\x1b[2J\x1b[H" __FILE__ "\r\n" __DATE__ " " __TIME__ " (UTC)\r\n""\r\n"; // RAM ------------------------------------------------------------------------ BatteryService *batteryService = NULL; @@ -94,7 +94,7 @@ // Here is a example to impliment the monitor // para: 1 -> goto montor and never comeback // ****************************************************** -#if 0 +#if 1 debug_interface(1); #endif @@ -153,7 +153,7 @@ // para: 0 -> if Uart RX Data is ready then goto montor // ****************************************************** debug_interface(0); - Thread::wait(1000); + ThisThread::sleep_for(1000); } }
--- a/select_example.cpp Tue Feb 12 20:56:50 2019 +0000 +++ b/select_example.cpp Thu Dec 19 07:27:50 2019 +0000 @@ -1,12 +1,12 @@ /* * AE-TYBLE16 Module example programs * - * Copyright (c) 2018 Kenji Arai / JH1PJL + * Copyright (c) 2018,'19 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: April 7th, 2018 * Revised: April 15th, 2018 - * Revised: November 25th, 2018 Change os2 to os5 + * Revised: December 19th, 2019 */ @@ -35,55 +35,63 @@ https://os.mbed.com/users/kenjiArai/ code/TYBLE16_mbedlized_os5_several_examples_2/ 9. 9_Monitor - Check nRF51 CPU functions + Check TYBLE16/nRF51 CPU functions */ -#define EXAMPLE_NUMBER 5 // select 0 to 6 & 9 +#define EXAMPLE_NUMBER 9 // select 0 to 6 & 9 //----------------- You don't need any modification ---------------------------- #if EXAMPLE_NUMBER == 0 -#define EXAMPLE_0_BLINKY_LED -#ifdef EXAMPLE_0_BLINKY_LED -#include "0_Blinky_LED/main.cpp" -#endif + #define EXAMPLE_0_BLINKY_LED + #ifdef EXAMPLE_0_BLINKY_LED + #include "0_Blinky_LED/main.cpp" + #warning "Select 0_Blinky_LED" + #endif #elif EXAMPLE_NUMBER == 1 -#define EXAMPLE_1_CHECK_RTC -#ifdef EXAMPLE_1_CHECK_RTC -#include "1_Check_RTC/main.cpp" -#endif + #define EXAMPLE_1_CHECK_RTC + #ifdef EXAMPLE_1_CHECK_RTC + #include "1_Check_RTC/main.cpp" + #warning "Select 1_Check_RTC" + #endif #elif EXAMPLE_NUMBER == 2 -#define EXAMPLE_2_EDDYSTONE_BEACON -#ifdef EXAMPLE_2_EDDYSTONE_BEACON -#include "2_EddyStoneBeacon/main.cpp" -#endif + #define EXAMPLE_2_EDDYSTONE_BEACON + #ifdef EXAMPLE_2_EDDYSTONE_BEACON + #include "2_EddyStoneBeacon/main.cpp" + #warning "Select 2_EddyStoneBeacon" + #endif #elif EXAMPLE_NUMBER == 3 -#define EXAMPLE_3_HEART_RATE -#ifdef EXAMPLE_3_HEART_RATE -#include "3_Heart_Rate/main.cpp" -#endif + #define EXAMPLE_3_HEART_RATE + #ifdef EXAMPLE_3_HEART_RATE + #include "3_Heart_Rate/main.cpp" + #warning "Select 3_Heart_Rate" + #endif #elif EXAMPLE_NUMBER == 4 -#define EXAMPLE_4_RCB_CONTROLLER -#ifdef EXAMPLE_4_RCB_CONTROLLER -#include "4_RCBController/main.cpp" -#endif + #define EXAMPLE_4_RCB_CONTROLLER + #ifdef EXAMPLE_4_RCB_CONTROLLER + #include "4_RCBController/main.cpp" + #warning "Select 4_RCBController" + #endif #elif EXAMPLE_NUMBER == 5 -#define EXAMPLE_5_SDCARD -#ifdef EXAMPLE_5_SDCARD -#include "5_SDCard/main.cpp" -#endif + #define EXAMPLE_5_SDCARD + #ifdef EXAMPLE_5_SDCARD + #include "5_SDCard/main.cpp" + #warning "Select 5_SDCard" + #endif #elif EXAMPLE_NUMBER == 6 -#define EXAMPLE_6_THERMO -#ifdef EXAMPLE_6_THERMO -#include "6_Thermo/main.cpp" -#endif + #define EXAMPLE_6_THERMO + #ifdef EXAMPLE_6_THERMO + #include "6_Thermo/main.cpp" + #warning "Select 6_Thermo" + #endif #elif EXAMPLE_NUMBER == 7 -#error "Please use TYBLE16_mbedlized_os5_several_examples_2nd" + #error "Please use TYBLE16_mbedlized_os5_several_examples_2nd" #elif EXAMPLE_NUMBER == 8 -#error "Please use TYBLE16_mbedlized_os5_several_examples_2nd" + #error "Please use TYBLE16_mbedlized_os5_several_examples_2nd" #elif EXAMPLE_NUMBER == 9 -#define EXAMPLE_9_MONITOR -#ifdef EXAMPLE_9_MONITOR -#include "9_Monitor/main.cpp" + #define EXAMPLE_9_MONITOR + #ifdef EXAMPLE_9_MONITOR + #include "9_Monitor/main.cpp" + #warning "Select 9_Monitor" + #endif +#else + #error " Please set 0 to 9 number for EXAMPLE_NUMBER!!" #endif -#else -#error " Please set 0 to 9 number for EXAMPLE_NUMBER!!" -#endif