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: N5110 ShiftReg Tone mbed
Fork of 1620_Project_Template by
ModeA.cpp
00001 #include "ModeA.h" 00002 00003 DigitalOut myled1(LED1); 00004 DigitalOut myled2(LED2); 00005 DigitalOut myled3(LED3); 00006 DigitalOut myled4(LED4); 00007 00008 void mode_A() 00009 { 00010 00011 lcd.clear(); 00012 00013 00014 lcd.printString("Mode A",0,0); 00015 lcd.refresh(); 00016 wait_ms(250); // small delay to prevent previous press being detected again 00017 00018 while (button_a.read() == 0) { // code goes in here - this acts like the main while(1) loop 00019 00020 lcd.clear(); 00021 00022 lcd.printString("Mode A",0,0); 00023 00024 int petrol[12][11] = { 00025 { 0,0,1,1,1,1,1,0,0,0,0 }, 00026 { 0,0,1,0,0,0,1,0,0,1,1 }, 00027 { 0,0,1,0,0,0,1,0,0,1,1 }, 00028 { 0,0,1,0,0,0,1,0,0,0,1 }, 00029 { 0,0,1,0,0,0,1,0,0,1,0 }, 00030 { 0,0,1,1,1,1,1,0,0,1,0 }, 00031 { 0,0,1,1,1,1,1,0,1,0,0 }, 00032 { 0,0,1,1,1,1,1,0,1,0,0 }, 00033 { 0,0,1,1,1,1,1,1,0,0,0 }, 00034 { 0,0,1,1,1,1,1,0,0,0,0 }, 00035 { 1,1,1,1,1,1,1,1,1,0,0 }, 00036 { 1,1,1,1,1,1,1,1,1,0,0 }, 00037 }; 00038 lcd.drawSprite(3,10,12,11,(int *)petrol); 00039 00040 int temp[19][3] = { 00041 { 0,1,0}, 00042 { 1,0,1}, 00043 { 1,0,1}, 00044 { 1,0,1}, 00045 { 1,0,1}, 00046 { 1,0,1}, 00047 { 1,0,1}, 00048 { 1,0,1}, 00049 { 1,0,1}, 00050 { 1,0,1}, 00051 { 1,0,1}, 00052 { 1,0,1}, 00053 { 1,0,1}, 00054 { 1,0,1}, 00055 { 0,1,0}, 00056 { 1,1,1}, 00057 { 1,1,1}, 00058 { 1,0,1}, 00059 { 1,1,1}, 00060 }; 00061 lcd.drawSprite(6,27,19,3,(int *)temp); 00062 00063 float pot0_val = pot_0.read(); 00064 float pot1_val = pot_1.read(); 00065 00066 lcd.drawRect(16,10,68,12,FILL_TRANSPARENT); // Fuel Bar 00067 lcd.drawRect(16,30,68,12,FILL_TRANSPARENT); // Temperature Bar 00068 00069 float W1=pot0_val*67; 00070 float W2=(pot1_val*67); 00071 00072 lcd.drawRect(17,11,W1,10,FILL_BLACK); 00073 lcd.drawRect(17,31,W2,10,FILL_BLACK); 00074 00075 float Fuel_lvl=pot0_val*100; 00076 float Engine_temp=(pot1_val*80)+50; 00077 printf("Fuel level = %.02f%% Engine temperature = %.02f Degrees C\n", Fuel_lvl, Engine_temp); 00078 00079 if (Fuel_lvl<20) { 00080 myled4=1; 00081 } else { 00082 myled4=0; 00083 } 00084 00085 if (Engine_temp>110) { 00086 myled1=1; 00087 } else { 00088 myled1=0; 00089 } 00090 00091 00092 lcd.refresh(); 00093 wait_ms(100); 00094 } 00095 00096 }
Generated on Wed Jul 13 2022 07:12:38 by
1.7.2
