スマートコンセント PS-5204PSをmbedで
Dependencies: FatFileSystemCpp mbed TextLCD
Fork of BlueUSB by
Fusjitsu スマートコンセント FX-5204PSを利用できます。
BlueUSBを利用していますが、Bluetoothは兼用できません。
複数台利用するには、USBハブを使用してください。ただし相性があります。
・良ければ10台まで利用できるかも。
・稼働中に追加はできますが、外すことはできません。
LED1-3, スマートコンセント接続状態(3台まで表示)
LED4、点滅で正常動作
Diff: main.cpp
- Revision:
- 2:32a2d06f4fe2
- Parent:
- 1:3f2890d103fb
--- a/main.cpp Wed Sep 26 06:29:47 2012 +0000 +++ b/main.cpp Thu Sep 27 13:04:36 2012 +0000 @@ -24,6 +24,7 @@ #include "USBHost.h" #include "Utils.h" #include "FATFileSystem.h" +#include "TextLCD.h" int MassStorage_ReadCapacity(int device, u32* blockCount, u32* blockSize); int MassStorage_Read(int device, u32 blockAddr, u32 blockCount, u8* dst, u32 blockSize); @@ -102,26 +103,42 @@ pc.putc(c); // echo return c; } - -void TestShell(); void InitUSPS(); void USPS_Refresh(); DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); Timer t; +Timer t2; +TextLCD lcd(p24, p26, p27, p28, p29, p30); +extern float WattData1[],WattData2[],WattData3[],WattData4[]; +extern int SerialNo[]; int main() { pc.baud(460800); - printf("BlueUSB\nNow get a bunch of usb or bluetooth things and plug them in\n"); InitUSPS(); - //TestShell(); - USBInit(); - t.start(); - while(1){ - USBLoop(); - if(t>1 ){ - t.start(); - led1=!led1; -USPS_Refresh(); - } - } + USBInit(); + t.start(); + t2.start(); + lcd.cls(); + lcd.printf("Watting...."); + while(1) { + USBLoop(); + if(t>0.1 ) { + t.start(); + led4=!led4; + USPS_Refresh(); + } + if(t2>1){ + t2.start(); + if(SerialNo[0]==0)led1=0;else led1=1; + if(SerialNo[1]==0)led2=0;else led2=1; + if(SerialNo[2]==0)led3=0;else led3=1; + lcd.locate(0,0); + lcd.printf("1:%4.0fW 2:%4.0fW",WattData1[0],WattData2[0]); + lcd.locate(0,1); + lcd.printf("3:%4.0fW 4:%4.0fW",WattData3[0],WattData4[0]); + } + } }