Talk Watch system using NTP timer for JBB.
Dependencies: EthernetNetIf FatFileSystem HTTPClient_ToBeRemoved HTTPServer NTPClient_NetServices TextLCD mbed
Fork of StarBoardOrangeTest3 by
Revision 1:8816ea8be54b, committed 2014-06-22
- Comitter:
- y_notsu
- Date:
- Sun Jun 22 05:12:34 2014 +0000
- Parent:
- 0:ae31fe6f181c
- Commit message:
- Talk Watch using NTP client for JBB
Changed in this revision
diff -r ae31fe6f181c -r 8816ea8be54b FATFileSystem.lib --- a/FATFileSystem.lib Thu Feb 23 14:35:52 2012 +0000 +++ b/FATFileSystem.lib Sun Jun 22 05:12:34 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_unsupported/code/fatfilesystem/ \ No newline at end of file +http://mbed.org/users/mbed_unsupported/code/FatFileSystem/#333d6e93e58f
diff -r ae31fe6f181c -r 8816ea8be54b HTTPClient.lib --- a/HTTPClient.lib Thu Feb 23 14:35:52 2012 +0000 +++ b/HTTPClient.lib Sun Jun 22 05:12:34 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/HTTPClient/#d0be6af2d1db +http://mbed.org/users/donatien/code/HTTPClient_ToBeRemoved/#d0be6af2d1db
diff -r ae31fe6f181c -r 8816ea8be54b NTPClient.lib --- a/NTPClient.lib Thu Feb 23 14:35:52 2012 +0000 +++ b/NTPClient.lib Sun Jun 22 05:12:34 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/NTPClient/#7c3f1199256a +http://mbed.org/users/donatien/code/NTPClient_NetServices/#7c3f1199256a
diff -r ae31fe6f181c -r 8816ea8be54b main.cpp --- a/main.cpp Thu Feb 23 14:35:52 2012 +0000 +++ b/main.cpp Sun Jun 22 05:12:34 2014 +0000 @@ -72,10 +72,12 @@ DigitalOut led1(LED1); DigitalOut led4(LED4); - DigitalIn SW1(p15); - DigitalIn SW2(p16); - DigitalIn TGSW(p17); + DigitalIn SW1(p25); + DigitalIn SW2(p26); + int TGSW=1; DigitalIn SW3(p14); + DigitalOut AMPEnable(p12); //0:Off, 1:On + Serial pc(USBTX, USBRX); // tx, rx int playflg; int playflg2; @@ -102,11 +104,12 @@ int main() { WavPlayer myWavPlayer; - + SW1.mode(PullUp); + SW2.mode(PullUp); led1 = 1 ; playflg = 0; playflg2 = 0; - printf("\r\n--------------- Starting -----------------\r\n"); + pc.printf("\r\n--------------- Starting -----------------\r\n"); lcd.printf("----Starting----"); lcd.locate(0,1); wait(3); @@ -114,165 +117,34 @@ wait(2); //test_file_write( "USB storage", "/usb/star_bd.txt" ); //wait( 2 ); + AMPEnable=0; myWavPlayer.play_wave("/sd/startup.wav"); wait(0.5); myWavPlayer.play_wave("/sd/startup2.wav"); lcd.cls(); - printf("\r\nSetting up...\r\n"); + AMPEnable=0; + pc.printf("\r\nSetting up...\r\n"); lcd.printf("Setting up...\n"); if(TGSW==1) { EthernetErr ethErr = eth.setup(); if (ethErr) { - printf("Error %d in setup.\n", ethErr); + pc.printf("Error %d in setup.\n", ethErr); lcd.printf("Error %d in setup.\n", ethErr); return -1; } } lcd.locate(0,1); - printf("\r\nSetup OK\r\n"); + pc.printf("\r\nSetup OK\r\n"); wait(1); //test_httpserver(); - if(TGSW) - { //RTC setup Host server(IpAddr(), 123, ntp_server); ntp.setTime(server); timest=1; - } - else - { - //Internal RTC mode - // setup time structure for 29 Oct 2010 00:00:00 - struct tm t; - t.tm_sec = 00; // 0-59 - t.tm_min = 00; // 0-59 - t.tm_hour = 00; // 0-23 - t.tm_mday = 1; // 1-31 - t.tm_mon = 1; // 0-11 - t.tm_year = 110; // year since 1900 - ctTime = mktime(&t); - set_time(ctTime); - strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); - lcd.cls(); - lcd.printf("%s",buf); - //lcd.locate(8,0); - //Adjustmnt Clock - //month - lcd.cls(); - lcd.printf("Month Setting"); - wait(1.0); - lcd.cls(); - lcd.printf("%s",buf); - while(SW2==0) - { - if(SW1) - { - t.tm_mon = t.tm_mon + 1; - ctTime = mktime(&t); - set_time(ctTime); - } - else if(SW3) - { - t.tm_mon = t.tm_mon - 1; - ctTime = mktime(&t); - set_time(ctTime); - } - strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); - lcd.cls(); - lcd.printf("%s",buf); - wait(0.5); - } - wait(1); - lcd.cls(); - lcd.printf("Day Setting"); - wait(1.0); - lcd.cls(); - lcd.printf("%s",buf); - // Day setting - //lcd.locate(11,0); - while(SW2==0) - { - if(SW1) - { - t.tm_mday = t.tm_mday + 1; - ctTime = mktime(&t); - set_time(ctTime); - } - else if(SW3) - { - t.tm_mday = t.tm_mday - 1; - ctTime = mktime(&t); - set_time(ctTime); - } - strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); - lcd.cls(); - lcd.printf("%s",buf); - wait(0.5); - } - wait(1.0); - lcd.cls(); - lcd.printf("Hour Setting"); - wait(1.0); - lcd.cls(); - lcd.printf("%s",buf); - // Hour setting - //lcd.locate(11,0); - while(SW2==0) - { - if(SW1) - { - t.tm_hour = t.tm_hour + 1; - ctTime = mktime(&t); - set_time(ctTime); - } - else if(SW3) - { - t.tm_hour = t.tm_hour - 1; - ctTime = mktime(&t); - set_time(ctTime); - } - strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); - lcd.cls(); - lcd.printf("%s",buf); - wait(0.5); - } - wait(1.0); - lcd.cls(); - lcd.printf("Min Setting"); - wait(1.0); - lcd.cls(); - lcd.printf("%s",buf); - // Min setting - //lcd.locate(11,0); - while(SW2==0) - { - if(SW1) - { - t.tm_min = t.tm_min + 1; - ctTime = mktime(&t); - set_time(ctTime); - } - else if(SW3) - { - t.tm_min = t.tm_min - 1; - ctTime = mktime(&t); - set_time(ctTime); - } - strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); - lcd.cls(); - lcd.printf("%s",buf); - wait(0.5); - } - wait(2.0); - strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); - lcd.cls(); - lcd.printf("%s",buf); - wait(1.0); - - } + lcd.cls(); lcd.printf("Time Set End"); wait(1); @@ -282,16 +154,13 @@ while(1) { lcd.cls(); - //lcd.printf("WAVE file select:"); - - if(TGSW==1)ctTime = time(NULL)+32400;//JST time - else ctTime = time(NULL); + ctTime = time(NULL)+32400;//JST time strftime(buf,sizeof(buf), " (%Y/%m/%d %a %p %I:%M:%S)", localtime(&ctTime)); lcd.printf("%s",buf); //wait(0.5); - if(SW1) + if(SW1==0) { if(buf[20]=='1') { @@ -417,30 +286,12 @@ playflg=1; } - //if(SW1) - //{ - // wavefilename1 = "/sd/1ji.wav"; - // wavefilename2 = "/sd/5min.wav"; - // wavefilename3 = "/sd/desu.wav"; - // playflg = 1; - //} - //if(SW2) - //{ - // wavefilename1 = "/sd/11ji.wav" ; - // wavefilename2 = "/sd/30.wav"; - // wavefilename3 = "/sd/7min.wav"; - // wavefilename4 = "/sd/desu.wav"; - // playflg =1; - //playflg2 = 1; - //} if(playflg==1) { lcd.cls(); lcd.printf("%s", buf); - //lcd.printf("Wave file playing"); - //lcd.locate(0,1); - //lcd.printf(wavefilename1); + AMPEnable=0; myWavPlayer.play_wave(wavefilename1); // 8 bit sample size myWavPlayer.play_wave(wavefilename2); myWavPlayer.play_wave(wavefilename3); @@ -448,13 +299,15 @@ { myWavPlayer.play_wave(wavefilename4); } + AMPEnable=1; led1 = 0; led4 = 1; } - if(SW2) + if(SW2==0) { + AMPEnable=0; myWavPlayer.play_wave("/sd/doubler.wav"); - + AMPEnable=0; } wait(0.2); @@ -462,7 +315,9 @@ led1 = 1; playflg =0; playflg2=0; + } + } @@ -483,49 +338,6 @@ } -/* -void test_httpserver( void ) { - DigitalOut led1( LED1 ); - lcd.locate( 0, position() ); - lcd.printf( "HTTP srv: " ); - - Base::add_rpc_class<DigitalOut>(); - - printf("Setting up...n"); - EthernetErr ethErr = eth.setup(); - if ( ethErr ) { - lcd.printf( "error" ); - error( "error @ eth.setup()\n" ); - } - lcd.printf("OK "); - - FSHandler::mount("/local", "/"); //Mount /webfs path on web root path - FSHandler::mount("/sd", "/sd"); //Mount /webfs path on web sd path - //FSHandler::mount("/usb", "/usb"); //Mount /webfs path on web usb path - - svr.addHandler<FSHandler>("/"); //Default handler - svr.addHandler<FSHandler>("/sd"); - //svr.addHandler<FSHandler>("/usb"); - //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm - - svr.bind(80); - - lcd.locate( 5, position() -1 ); - lcd.printf("Listening"); - - Timer tm; - tm.start(); - //Listen indefinitely - while (true) { - Net::poll(); - if (tm.read()>.5) { - led1=!led1; //Show that we are alive - tm.start(); - } - } -} -*/ - int position( void ) { static int p = 0;
diff -r ae31fe6f181c -r 8816ea8be54b mbed.bld --- a/mbed.bld Thu Feb 23 14:35:52 2012 +0000 +++ b/mbed.bld Sun Jun 22 05:12:34 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e \ No newline at end of file