デバッグ用V850データ表示

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

Committer:
NT32
Date:
Sun May 24 08:11:04 2015 +0000
Revision:
3:ce52092b7a3a
Parent:
2:ad0b044d0a10
Child:
4:7ad4177061bb
i2c ??? LCD ?? ???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:334327d1a416 1 #include "mbed.h"
simon 0:334327d1a416 2 #include "TextLCD.h"
simon 0:334327d1a416 3
NT32 3:ce52092b7a3a 4 I2CSlave i2cslave(dp5, dp27);
NT32 3:ce52092b7a3a 5
NT32 3:ce52092b7a3a 6 DigitalOut led1(LED1);
NT32 3:ce52092b7a3a 7 DigitalOut led2(LED2);
NT32 3:ce52092b7a3a 8
NT32 3:ce52092b7a3a 9 TextLCD lcd(dp17, dp18, dp25, dp10, dp26, dp28, TextLCD::LCD20x4); // rs, e, d4-d7
NT32 3:ce52092b7a3a 10
simon 0:334327d1a416 11
simon 0:334327d1a416 12 int main() {
NT32 3:ce52092b7a3a 13 char str[20];
NT32 3:ce52092b7a3a 14 float SystemVoltage, AverageCellVoltage, MaxCellVoltage, MinimumCellVoltage,
NT32 3:ce52092b7a3a 15 SystemCurrent, Motor1Current, Motor2Current, Motor3Current,
NT32 3:ce52092b7a3a 16 Remain, PowerConsumption, IntegralPowerConsumption, IntegralCurrent;
NT32 3:ce52092b7a3a 17
NT32 3:ce52092b7a3a 18 int MaxCellNumber, MinimumCellNumber;
NT32 3:ce52092b7a3a 19 int32_t cellvol[12], mincell, maxcell;
NT32 3:ce52092b7a3a 20 float realcellvol; /* real number of cell voltage */
NT32 3:ce52092b7a3a 21
NT32 3:ce52092b7a3a 22 char rbuf[64];
NT32 3:ce52092b7a3a 23 char i2cbuf[32] = {0};
NT32 3:ce52092b7a3a 24
NT32 3:ce52092b7a3a 25 SystemVoltage = 120.5; //%4.1f システム電圧
NT32 3:ce52092b7a3a 26 AverageCellVoltage = 3.123; //%4.3f 平均セル電圧
NT32 3:ce52092b7a3a 27 MaxCellVoltage = 1.234; //%4.3f
NT32 3:ce52092b7a3a 28 MinimumCellVoltage = 0.123; //%4.3f
NT32 3:ce52092b7a3a 29 MaxCellNumber = 5; //%1d
NT32 3:ce52092b7a3a 30 MinimumCellNumber = 3; //%1d
NT32 3:ce52092b7a3a 31 SystemCurrent = 138.1235; //%3.0f
NT32 3:ce52092b7a3a 32 Motor1Current = 11.1245; //%3.0f
NT32 3:ce52092b7a3a 33 Motor2Current = 22.1245; //%3.0f
NT32 3:ce52092b7a3a 34 Motor3Current = 33.1245; //%3.0f
NT32 3:ce52092b7a3a 35 Remain = 85.435; //%3.0f
NT32 3:ce52092b7a3a 36 PowerConsumption = 12.54; //%4.2f
NT32 3:ce52092b7a3a 37 IntegralPowerConsumption = 1.54; //%3.2f
NT32 3:ce52092b7a3a 38 IntegralCurrent = 43.21; //%4.2f
NT32 3:ce52092b7a3a 39
NT32 3:ce52092b7a3a 40 lcd.cls();
NT32 3:ce52092b7a3a 41 lcd.locate(0, 0);
NT32 3:ce52092b7a3a 42 lcd.locate(0, 1);
NT32 3:ce52092b7a3a 43 lcd.printf("%4.3fV", AverageCellVoltage);
NT32 3:ce52092b7a3a 44 lcd.locate(0, 2);
NT32 3:ce52092b7a3a 45 lcd.printf("%4.3fV%d", MaxCellVoltage, MaxCellNumber);
NT32 3:ce52092b7a3a 46 lcd.locate(0, 3);
NT32 3:ce52092b7a3a 47 lcd.printf("%4.3fV%d", MinimumCellVoltage, MinimumCellNumber);
NT32 3:ce52092b7a3a 48 lcd.locate(8, 0);
NT32 3:ce52092b7a3a 49 lcd.printf("%3.0fA", SystemCurrent);
NT32 3:ce52092b7a3a 50 lcd.locate(8, 1);
NT32 3:ce52092b7a3a 51 lcd.printf("%3.0fA", Motor1Current);
NT32 3:ce52092b7a3a 52 lcd.locate(8, 2);
NT32 3:ce52092b7a3a 53 lcd.printf("%3.0fA", Motor2Current);
NT32 3:ce52092b7a3a 54 lcd.locate(8, 3);
NT32 3:ce52092b7a3a 55 lcd.printf("%3.0fA", Motor3Current);
NT32 3:ce52092b7a3a 56 lcd.locate(16, 0);
NT32 3:ce52092b7a3a 57 lcd.printf("%3.0fA", Remain);
NT32 3:ce52092b7a3a 58 lcd.locate(13, 1);
NT32 3:ce52092b7a3a 59 lcd.printf("%4.2fkW", PowerConsumption);
NT32 3:ce52092b7a3a 60 lcd.locate(13, 2);
NT32 3:ce52092b7a3a 61 lcd.printf("%3.2fkWh", IntegralPowerConsumption);
NT32 3:ce52092b7a3a 62 lcd.locate(13, 3);
NT32 3:ce52092b7a3a 63 lcd.printf("%4.2fAh", IntegralCurrent);
NT32 3:ce52092b7a3a 64
NT32 3:ce52092b7a3a 65 i2cslave.address(0x33);
NT32 3:ce52092b7a3a 66 i2cslave.frequency(100000);
NT32 3:ce52092b7a3a 67
NT32 3:ce52092b7a3a 68 while(1){
NT32 3:ce52092b7a3a 69 if(i2cslave.receive() != I2CSlave::NoData){
NT32 3:ce52092b7a3a 70 i2cslave.read(i2cbuf, 7);
NT32 3:ce52092b7a3a 71 lcd.locate(0, 0);
NT32 3:ce52092b7a3a 72 led1 != led1;
NT32 3:ce52092b7a3a 73 lcd.printf("%s", i2cbuf);
NT32 3:ce52092b7a3a 74 }
NT32 3:ce52092b7a3a 75 }
NT32 3:ce52092b7a3a 76 }