You need to drink more water

Dependencies:   HX711 SeeedGrayOLED XBeeLib mbed

Committer:
jehoon
Date:
Wed Sep 23 04:07:27 2015 +0000
Revision:
0:6b3f26e7b431
you need to drink more water

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jehoon 0:6b3f26e7b431 1 #include "mbed.h"
jehoon 0:6b3f26e7b431 2 #include "XBeeLib.h"
jehoon 0:6b3f26e7b431 3 #include "HX711.h"
jehoon 0:6b3f26e7b431 4 #include "SeeedGrayOLED.h" // Seeed Grove: OLED Display 0.96" 96x96
jehoon 0:6b3f26e7b431 5
jehoon 0:6b3f26e7b431 6 #define REMOTE_NODE_ADDR64_MSB ((uint32_t)0x0013A200)
jehoon 0:6b3f26e7b431 7 #define REMOTE_NODE_ADDR64_LSB ((uint32_t)0x40e8282a)
jehoon 0:6b3f26e7b431 8 //#define REMOTE_NODE_ADDR64_LSB ((uint32_t)0x40B8EBCE)
jehoon 0:6b3f26e7b431 9
jehoon 0:6b3f26e7b431 10 #define REMOTE_NODE_ADDR16 ((uint16_t)0xFFFF)
jehoon 0:6b3f26e7b431 11 #define REMOTE_NODE_ADDR64 UINT64(REMOTE_NODE_ADDR64_MSB, REMOTE_NODE_ADDR64_LSB)
jehoon 0:6b3f26e7b431 12
jehoon 0:6b3f26e7b431 13 ////
jehoon 0:6b3f26e7b431 14 #define BOTTLE_SAMPLE_RATE 10
jehoon 0:6b3f26e7b431 15 #define MAX_WATER 2000 // 2L
jehoon 0:6b3f26e7b431 16 unsigned int waterlog = 0;
jehoon 0:6b3f26e7b431 17
jehoon 0:6b3f26e7b431 18 ////
jehoon 0:6b3f26e7b431 19 enum dataType {
jehoon 0:6b3f26e7b431 20 REQTOTAL = 0,
jehoon 0:6b3f26e7b431 21 SENDDATA
jehoon 0:6b3f26e7b431 22 };
jehoon 0:6b3f26e7b431 23
jehoon 0:6b3f26e7b431 24 enum status {
jehoon 0:6b3f26e7b431 25 NEED_SET_DEFAULT = 0,
jehoon 0:6b3f26e7b431 26 SET_DEFAULT,
jehoon 0:6b3f26e7b431 27 CHECK_BOTTLE,
jehoon 0:6b3f26e7b431 28 SENSE_WATER_LEVEL,
jehoon 0:6b3f26e7b431 29 WAIT_INPUT
jehoon 0:6b3f26e7b431 30 };
jehoon 0:6b3f26e7b431 31
jehoon 0:6b3f26e7b431 32
jehoon 0:6b3f26e7b431 33 using namespace XBeeLib;
jehoon 0:6b3f26e7b431 34
jehoon 0:6b3f26e7b431 35 Serial pc(DEBUG_TX, DEBUG_RX);
jehoon 0:6b3f26e7b431 36 HX711 gram(A1, A0, 64);
jehoon 0:6b3f26e7b431 37 DigitalIn default_button(D7);
jehoon 0:6b3f26e7b431 38 DigitalIn bottle_weight(D8);
jehoon 0:6b3f26e7b431 39 DigitalOut LED(D6);
jehoon 0:6b3f26e7b431 40 SeeedGrayOLED SeeedGrayOled(D14, D15);
jehoon 0:6b3f26e7b431 41
jehoon 0:6b3f26e7b431 42 void Draw_OLED_log(uint8_t val);
jehoon 0:6b3f26e7b431 43 void OLED_Display(float val);
jehoon 0:6b3f26e7b431 44
jehoon 0:6b3f26e7b431 45
jehoon 0:6b3f26e7b431 46 static void receiveXbee(const RemoteXBee802& remote, bool broadcast, const uint8_t *const data, uint16_t len)
jehoon 0:6b3f26e7b431 47 {
jehoon 0:6b3f26e7b431 48 char tmp[50] = {'\0'};
jehoon 0:6b3f26e7b431 49
jehoon 0:6b3f26e7b431 50 #ifdef _DBG
jehoon 0:6b3f26e7b431 51
jehoon 0:6b3f26e7b431 52 if (remote.is_valid_addr16b()) {
jehoon 0:6b3f26e7b431 53 printf("\r\n>> Got a %s 16-bit RX packet [%04x], len %d\r\nData: ", broadcast ? "BROADCAST" : "UNICAST", remote.get_addr16(), len);
jehoon 0:6b3f26e7b431 54 } else {
jehoon 0:6b3f26e7b431 55 printf("\r\n>> Got a %s 64-bit RX packet [%08x:%08x], len %d\r\nData: ", broadcast ? "BROADCAST" : "UNICAST", remote.get_addr64(), len);
jehoon 0:6b3f26e7b431 56 }
jehoon 0:6b3f26e7b431 57 #endif
jehoon 0:6b3f26e7b431 58
jehoon 0:6b3f26e7b431 59 for (int i = 1; i < len; i++){
jehoon 0:6b3f26e7b431 60 printf("%c", data[i]);
jehoon 0:6b3f26e7b431 61 tmp[i - 1] = data[i];
jehoon 0:6b3f26e7b431 62 }
jehoon 0:6b3f26e7b431 63 printf("\r\n");
jehoon 0:6b3f26e7b431 64
jehoon 0:6b3f26e7b431 65 if(!strncmp("init",(char*)data,len)){
jehoon 0:6b3f26e7b431 66 waterlog = 0;
jehoon 0:6b3f26e7b431 67
jehoon 0:6b3f26e7b431 68 }
jehoon 0:6b3f26e7b431 69
jehoon 0:6b3f26e7b431 70 }
jehoon 0:6b3f26e7b431 71 static void sendRemoteXbee(XBee802& xbee, const RemoteXBee802& RemoteDevice, uint8_t type ,long weight)
jehoon 0:6b3f26e7b431 72 {
jehoon 0:6b3f26e7b431 73 char data[20] = {'\0'};
jehoon 0:6b3f26e7b431 74 sprintf(data, "%1d%i\0",type, weight);
jehoon 0:6b3f26e7b431 75
jehoon 0:6b3f26e7b431 76 const uint16_t data_len = strlen(data);
jehoon 0:6b3f26e7b431 77
jehoon 0:6b3f26e7b431 78 const TxStatus txStatus = xbee.send_data(RemoteDevice, (const uint8_t *)data, data_len);
jehoon 0:6b3f26e7b431 79
jehoon 0:6b3f26e7b431 80 if (txStatus == TxStatusSuccess)
jehoon 0:6b3f26e7b431 81 printf(">> Send_data_to_remote_node OK... %s\r\n",data);
jehoon 0:6b3f26e7b431 82 else
jehoon 0:6b3f26e7b431 83 printf(">> send_data_to_remote_node failed with %d\r\n", (int)txStatus);
jehoon 0:6b3f26e7b431 84 }
jehoon 0:6b3f26e7b431 85
jehoon 0:6b3f26e7b431 86 int checkWeight(){
jehoon 0:6b3f26e7b431 87 long sum = 0;
jehoon 0:6b3f26e7b431 88
jehoon 0:6b3f26e7b431 89 for(int i = 0; i < BOTTLE_SAMPLE_RATE; i++){
jehoon 0:6b3f26e7b431 90 sum += gram.getGram();
jehoon 0:6b3f26e7b431 91 wait_ms(100);
jehoon 0:6b3f26e7b431 92 }
jehoon 0:6b3f26e7b431 93
jehoon 0:6b3f26e7b431 94 return sum / BOTTLE_SAMPLE_RATE;
jehoon 0:6b3f26e7b431 95 }
jehoon 0:6b3f26e7b431 96
jehoon 0:6b3f26e7b431 97
jehoon 0:6b3f26e7b431 98 void ledBlink(int cnt, int delay_ms = 50){
jehoon 0:6b3f26e7b431 99
jehoon 0:6b3f26e7b431 100 LED = 0;
jehoon 0:6b3f26e7b431 101
jehoon 0:6b3f26e7b431 102 for(int i = 0; i < cnt; i++){
jehoon 0:6b3f26e7b431 103 LED = 1;
jehoon 0:6b3f26e7b431 104 wait_ms(delay_ms);
jehoon 0:6b3f26e7b431 105 LED = 0;
jehoon 0:6b3f26e7b431 106 wait_ms(delay_ms);
jehoon 0:6b3f26e7b431 107 }
jehoon 0:6b3f26e7b431 108 }
jehoon 0:6b3f26e7b431 109 //////////////////////////////////////
jehoon 0:6b3f26e7b431 110 //////////////////////////////////////
jehoon 0:6b3f26e7b431 111 //////////////////////////////////////
jehoon 0:6b3f26e7b431 112 //////////////////////////////////////
jehoon 0:6b3f26e7b431 113 //////////////////////////////////////
jehoon 0:6b3f26e7b431 114 //////////////////////////////////////
jehoon 0:6b3f26e7b431 115 //////////////////////////////////////
jehoon 0:6b3f26e7b431 116
jehoon 0:6b3f26e7b431 117 int main()
jehoon 0:6b3f26e7b431 118 {
jehoon 0:6b3f26e7b431 119 pc.baud(9600);
jehoon 0:6b3f26e7b431 120
jehoon 0:6b3f26e7b431 121 XBee802 xbee = XBee802(RADIO_TX, RADIO_RX, RADIO_RESET, NC, NC, 9600);
jehoon 0:6b3f26e7b431 122
jehoon 0:6b3f26e7b431 123
jehoon 0:6b3f26e7b431 124 /* Register callback */
jehoon 0:6b3f26e7b431 125 xbee.register_receive_cb(&receiveXbee);
jehoon 0:6b3f26e7b431 126 RadioStatus const radioStatus = xbee.init();
jehoon 0:6b3f26e7b431 127 MBED_ASSERT(radioStatus == Success);
jehoon 0:6b3f26e7b431 128 const RemoteXBee802 remoteDevice64b = RemoteXBee802(REMOTE_NODE_ADDR64);
jehoon 0:6b3f26e7b431 129
jehoon 0:6b3f26e7b431 130 SeeedGrayOled.init(); // Initialize SEEED OLED display
jehoon 0:6b3f26e7b431 131 SeeedGrayOled.clearDisplay(); // Clear Display
jehoon 0:6b3f26e7b431 132 SeeedGrayOled.setNormalDisplay(); // Set Normal Display Mode
jehoon 0:6b3f26e7b431 133
jehoon 0:6b3f26e7b431 134 // for(int i=0; i<2000; i+=100)
jehoon 0:6b3f26e7b431 135 // OLED_Display((float)i);
jehoon 0:6b3f26e7b431 136 OLED_Display(0);
jehoon 0:6b3f26e7b431 137
jehoon 0:6b3f26e7b431 138 long Weight; //current weight
jehoon 0:6b3f26e7b431 139 long botWeight = 0; //bottle weight
jehoon 0:6b3f26e7b431 140
jehoon 0:6b3f26e7b431 141 long WaterLevel = 0;
jehoon 0:6b3f26e7b431 142 long pWaterLevel = 0;
jehoon 0:6b3f26e7b431 143 long dWaterLevel = 0;
jehoon 0:6b3f26e7b431 144 uint8_t Status;
jehoon 0:6b3f26e7b431 145
jehoon 0:6b3f26e7b431 146 Status = NEED_SET_DEFAULT;
jehoon 0:6b3f26e7b431 147
jehoon 0:6b3f26e7b431 148
jehoon 0:6b3f26e7b431 149
jehoon 0:6b3f26e7b431 150 while (true) {
jehoon 0:6b3f26e7b431 151 if(!default_button)
jehoon 0:6b3f26e7b431 152 Status = SET_DEFAULT;
jehoon 0:6b3f26e7b431 153 else if(!bottle_weight)
jehoon 0:6b3f26e7b431 154 Status = CHECK_BOTTLE;
jehoon 0:6b3f26e7b431 155
jehoon 0:6b3f26e7b431 156 switch(Status){
jehoon 0:6b3f26e7b431 157 case NEED_SET_DEFAULT:
jehoon 0:6b3f26e7b431 158 // printf(">>> You need to set the default.\n>>>Press the SET KEY\n\n");
jehoon 0:6b3f26e7b431 159 printf(".");
jehoon 0:6b3f26e7b431 160 wait(1);
jehoon 0:6b3f26e7b431 161 break;
jehoon 0:6b3f26e7b431 162
jehoon 0:6b3f26e7b431 163 case SET_DEFAULT:
jehoon 0:6b3f26e7b431 164 gram.tare();
jehoon 0:6b3f26e7b431 165 ledBlink(1, 100);
jehoon 0:6b3f26e7b431 166
jehoon 0:6b3f26e7b431 167 printf(">>> Set the base weight\n");
jehoon 0:6b3f26e7b431 168 Weight = 0;
jehoon 0:6b3f26e7b431 169 botWeight = 0;
jehoon 0:6b3f26e7b431 170 WaterLevel = 0;
jehoon 0:6b3f26e7b431 171 pWaterLevel = 0;
jehoon 0:6b3f26e7b431 172
jehoon 0:6b3f26e7b431 173 Status = WAIT_INPUT;
jehoon 0:6b3f26e7b431 174 break;
jehoon 0:6b3f26e7b431 175
jehoon 0:6b3f26e7b431 176 case CHECK_BOTTLE:
jehoon 0:6b3f26e7b431 177 pWaterLevel = 0;
jehoon 0:6b3f26e7b431 178 botWeight = checkWeight();
jehoon 0:6b3f26e7b431 179 printf(">>> Your Bottle is %i g\n", botWeight);
jehoon 0:6b3f26e7b431 180 ledBlink(3);
jehoon 0:6b3f26e7b431 181 Status = SENSE_WATER_LEVEL;
jehoon 0:6b3f26e7b431 182
jehoon 0:6b3f26e7b431 183 break;
jehoon 0:6b3f26e7b431 184
jehoon 0:6b3f26e7b431 185 case SENSE_WATER_LEVEL:
jehoon 0:6b3f26e7b431 186
jehoon 0:6b3f26e7b431 187 Weight = checkWeight();
jehoon 0:6b3f26e7b431 188 WaterLevel = Weight - botWeight;
jehoon 0:6b3f26e7b431 189 printf("W: %i \t B: %i\n",WaterLevel,pWaterLevel);
jehoon 0:6b3f26e7b431 190
jehoon 0:6b3f26e7b431 191 if(WaterLevel <= 10 && WaterLevel > -10) // allowable error
jehoon 0:6b3f26e7b431 192 break;
jehoon 0:6b3f26e7b431 193 else if(WaterLevel <= -10){ // error
jehoon 0:6b3f26e7b431 194 printf("WaterLevel: %i\n",WaterLevel);
jehoon 0:6b3f26e7b431 195 //Status = NEED_SET_DEFAULT;
jehoon 0:6b3f26e7b431 196 break;
jehoon 0:6b3f26e7b431 197 }
jehoon 0:6b3f26e7b431 198
jehoon 0:6b3f26e7b431 199 if(WaterLevel < (pWaterLevel*0.95)){
jehoon 0:6b3f26e7b431 200
jehoon 0:6b3f26e7b431 201 wait(1);
jehoon 0:6b3f26e7b431 202 long check_again = checkWeight();
jehoon 0:6b3f26e7b431 203 if(check_again < (WaterLevel*0.98) || check_again > (WaterLevel*1.02))
jehoon 0:6b3f26e7b431 204 break;
jehoon 0:6b3f26e7b431 205
jehoon 0:6b3f26e7b431 206 dWaterLevel = pWaterLevel - WaterLevel;
jehoon 0:6b3f26e7b431 207 ledBlink(5);
jehoon 0:6b3f26e7b431 208 waterlog += dWaterLevel;
jehoon 0:6b3f26e7b431 209 OLED_Display((float)waterlog);
jehoon 0:6b3f26e7b431 210
jehoon 0:6b3f26e7b431 211 sendRemoteXbee(xbee, remoteDevice64b, SENDDATA,dWaterLevel);
jehoon 0:6b3f26e7b431 212 pWaterLevel = WaterLevel;
jehoon 0:6b3f26e7b431 213 }
jehoon 0:6b3f26e7b431 214 else if(WaterLevel > pWaterLevel){
jehoon 0:6b3f26e7b431 215 wait(1);
jehoon 0:6b3f26e7b431 216 long check_again = checkWeight();
jehoon 0:6b3f26e7b431 217 if(check_again < (WaterLevel*0.98) || check_again > (WaterLevel*1.02))
jehoon 0:6b3f26e7b431 218 break;
jehoon 0:6b3f26e7b431 219 pWaterLevel = WaterLevel;
jehoon 0:6b3f26e7b431 220 }
jehoon 0:6b3f26e7b431 221 break;
jehoon 0:6b3f26e7b431 222 case WAIT_INPUT:
jehoon 0:6b3f26e7b431 223 default:
jehoon 0:6b3f26e7b431 224 break;
jehoon 0:6b3f26e7b431 225 }
jehoon 0:6b3f26e7b431 226
jehoon 0:6b3f26e7b431 227
jehoon 0:6b3f26e7b431 228 wait_ms(100);
jehoon 0:6b3f26e7b431 229 }
jehoon 0:6b3f26e7b431 230
jehoon 0:6b3f26e7b431 231
jehoon 0:6b3f26e7b431 232 }
jehoon 0:6b3f26e7b431 233
jehoon 0:6b3f26e7b431 234
jehoon 0:6b3f26e7b431 235 void OLED_Display(float val)
jehoon 0:6b3f26e7b431 236 {
jehoon 0:6b3f26e7b431 237
jehoon 0:6b3f26e7b431 238 if(val < MAX_WATER*0.03)
jehoon 0:6b3f26e7b431 239 Draw_OLED_log(0);
jehoon 0:6b3f26e7b431 240 else if(val < MAX_WATER*0.10)
jehoon 0:6b3f26e7b431 241 Draw_OLED_log(10);
jehoon 0:6b3f26e7b431 242 else if(val < MAX_WATER*0.30)
jehoon 0:6b3f26e7b431 243 Draw_OLED_log(30);
jehoon 0:6b3f26e7b431 244 else if(val < MAX_WATER*0.40)
jehoon 0:6b3f26e7b431 245 Draw_OLED_log(40);
jehoon 0:6b3f26e7b431 246 else if(val < MAX_WATER*0.60)
jehoon 0:6b3f26e7b431 247 Draw_OLED_log(60);
jehoon 0:6b3f26e7b431 248 else if(val < MAX_WATER*0.70)
jehoon 0:6b3f26e7b431 249 Draw_OLED_log(70);
jehoon 0:6b3f26e7b431 250 else if(val < MAX_WATER*0.80)
jehoon 0:6b3f26e7b431 251 Draw_OLED_log(80);
jehoon 0:6b3f26e7b431 252 else if(val < MAX_WATER*0.90)
jehoon 0:6b3f26e7b431 253 Draw_OLED_log(90);
jehoon 0:6b3f26e7b431 254 else if(val < MAX_WATER)
jehoon 0:6b3f26e7b431 255 Draw_OLED_log(100);
jehoon 0:6b3f26e7b431 256 else
jehoon 0:6b3f26e7b431 257 Draw_OLED_log(0);
jehoon 0:6b3f26e7b431 258
jehoon 0:6b3f26e7b431 259 }
jehoon 0:6b3f26e7b431 260
jehoon 0:6b3f26e7b431 261 void Draw_OLED_log(uint8_t val)
jehoon 0:6b3f26e7b431 262 {
jehoon 0:6b3f26e7b431 263 SeeedGrayOled.setTextXY(0, 1);
jehoon 0:6b3f26e7b431 264 SeeedGrayOled.putString("more water");
jehoon 0:6b3f26e7b431 265
jehoon 0:6b3f26e7b431 266 SeeedGrayOled.setTextXY(11, 0);
jehoon 0:6b3f26e7b431 267 SeeedGrayOled.putString("Reach to 2L");
jehoon 0:6b3f26e7b431 268
jehoon 0:6b3f26e7b431 269 switch(val)
jehoon 0:6b3f26e7b431 270 {
jehoon 0:6b3f26e7b431 271 case 0:
jehoon 0:6b3f26e7b431 272 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 273 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 274 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 275 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 276 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 277 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 278 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 279 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 280 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 281 SeeedGrayOled.putString("| 0 % |");
jehoon 0:6b3f26e7b431 282 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 283 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 284 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 285 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 286 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 287 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 288 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 289 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 290 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 291 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 292 break;
jehoon 0:6b3f26e7b431 293 case 10:
jehoon 0:6b3f26e7b431 294 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 295 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 296 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 297 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 298 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 299 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 300 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 301 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 302 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 303 SeeedGrayOled.putString("| 10 % |");
jehoon 0:6b3f26e7b431 304 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 305 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 306 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 307 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 308 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 309 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 310 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 311 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 312 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 313 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 314 break;
jehoon 0:6b3f26e7b431 315 case 30:
jehoon 0:6b3f26e7b431 316 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 317 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 318 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 319 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 320 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 321 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 322 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 323 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 324 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 325 SeeedGrayOled.putString("| 30 % |");
jehoon 0:6b3f26e7b431 326 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 327 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 328 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 329 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 330 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 331 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 332 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 333 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 334 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 335 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 336 break;
jehoon 0:6b3f26e7b431 337 case 40:
jehoon 0:6b3f26e7b431 338 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 339 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 340 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 341 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 342 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 343 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 344 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 345 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 346 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 347 SeeedGrayOled.putString("| 40 % |");
jehoon 0:6b3f26e7b431 348 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 349 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 350 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 351 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 352 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 353 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 354 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 355 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 356 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 357 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 358 break;
jehoon 0:6b3f26e7b431 359 case 60:
jehoon 0:6b3f26e7b431 360 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 361 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 362 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 363 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 364 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 365 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 366 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 367 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 368 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 369 SeeedGrayOled.putString("| 60 % |");
jehoon 0:6b3f26e7b431 370 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 371 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 372 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 373 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 374 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 375 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 376 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 377 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 378 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 379 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 380 break;
jehoon 0:6b3f26e7b431 381 case 70:
jehoon 0:6b3f26e7b431 382 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 383 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 384 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 385 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 386 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 387 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 388 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 389 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 390 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 391 SeeedGrayOled.putString("|~~ 70 %~~|");
jehoon 0:6b3f26e7b431 392 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 393 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 394 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 395 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 396 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 397 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 398 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 399 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 400 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 401 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 402 break;
jehoon 0:6b3f26e7b431 403 case 80:
jehoon 0:6b3f26e7b431 404 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 405 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 406 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 407 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 408 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 409 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 410 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 411 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 412 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 413 SeeedGrayOled.putString("|~~ 80 %~~|");
jehoon 0:6b3f26e7b431 414 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 415 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 416 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 417 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 418 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 419 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 420 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 421 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 422 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 423 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 424 break;
jehoon 0:6b3f26e7b431 425 case 90:
jehoon 0:6b3f26e7b431 426 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 427 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 428 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 429 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 430 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 431 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 432 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 433 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 434 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 435 SeeedGrayOled.putString("|~~ 90 %~~|");
jehoon 0:6b3f26e7b431 436 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 437 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 438 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 439 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 440 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 441 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 442 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 443 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 444 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 445 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 446 break;
jehoon 0:6b3f26e7b431 447 case 100:
jehoon 0:6b3f26e7b431 448 SeeedGrayOled.setTextXY(1, 0);
jehoon 0:6b3f26e7b431 449 SeeedGrayOled.putString("===========");
jehoon 0:6b3f26e7b431 450 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 451 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 452 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 453 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 454 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 455 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 456 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 457 SeeedGrayOled.putString("|~~100 %~~|");
jehoon 0:6b3f26e7b431 458 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 459 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 460 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 461 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 462 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 463 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 464 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 465 SeeedGrayOled.putString("|~~~~~~~~~|");
jehoon 0:6b3f26e7b431 466 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 467 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 468 break;
jehoon 0:6b3f26e7b431 469 default: // 20
jehoon 0:6b3f26e7b431 470 SeeedGrayOled.setTextXY(2, 0);
jehoon 0:6b3f26e7b431 471 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 472 SeeedGrayOled.setTextXY(3, 0);
jehoon 0:6b3f26e7b431 473 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 474 SeeedGrayOled.setTextXY(4, 0);
jehoon 0:6b3f26e7b431 475 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 476 SeeedGrayOled.setTextXY(5, 0);
jehoon 0:6b3f26e7b431 477 SeeedGrayOled.putString("| 0 % |");
jehoon 0:6b3f26e7b431 478 SeeedGrayOled.setTextXY(6, 0);
jehoon 0:6b3f26e7b431 479 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 480 SeeedGrayOled.setTextXY(7, 0);
jehoon 0:6b3f26e7b431 481 SeeedGrayOled.putString("| ~");
jehoon 0:6b3f26e7b431 482 SeeedGrayOled.setTextXY(8, 0);
jehoon 0:6b3f26e7b431 483 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 484 SeeedGrayOled.setTextXY(9, 0);
jehoon 0:6b3f26e7b431 485 SeeedGrayOled.putString("| |");
jehoon 0:6b3f26e7b431 486 SeeedGrayOled.setTextXY(10, 0);
jehoon 0:6b3f26e7b431 487 SeeedGrayOled.putString("-----------");
jehoon 0:6b3f26e7b431 488 break;
jehoon 0:6b3f26e7b431 489 }
jehoon 0:6b3f26e7b431 490 }
jehoon 0:6b3f26e7b431 491
jehoon 0:6b3f26e7b431 492
jehoon 0:6b3f26e7b431 493