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.
Revision 2:5e42a3c4fd80, committed 2021-04-22
- Comitter:
- noamnahum
- Date:
- Thu Apr 22 10:47:19 2021 +0000
- Parent:
- 1:f8372f3df8d2
- Child:
- 3:4c564ed930fc
- Commit message:
- fornadav;
Changed in this revision
| Communicator.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SerialLCD.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/Communicator.cpp Sun Apr 11 22:40:28 2021 +0000
+++ b/Communicator.cpp Thu Apr 22 10:47:19 2021 +0000
@@ -1,78 +1,93 @@
#include "mbed.h"
-Serial pc(USBTX,USBRX);
-float Pedal,Thorttle,Speed,Voltage =0; // This variables give DATA
-int RPM = 0;
-/* Pedal 0 -255
- Thorttle 0-255
- Speed 0-90
- RPM 0-10000
- Voltage 0-24 */
-
-int PedalError,ThorttleError,CANError,BSPDError,Shutdowncircuit,Brake =0; // This variables give 0 or 1
-int main(){
- int i,j,k,z = 0;
- int e = 0;
- pc.baud(115200);
-
+#include "SerialLCD.h"
+
+SerialLCD lcd(PA_9);
+
+uint8_t smiley[8] = {
+ 0x00,
+ 0x11,
+ 0x00,
+ 0x00,
+ 0x11,
+ 0x0E,
+ 0x00
+};
+
+int main() {
+ lcd.clear();
-while(1){
- pc.printf("P%.4f\n", Pedal);
- pc.printf("T%.4f\n", Thorttle);
- pc.printf("b%d\n", Brake);
- pc.printf("R%d\n", RPM);
- pc.printf("V%.4f\n", Voltage);
- pc.printf("S%.4f\n", Speed);
- pc.printf("C%d\n", CANError);
- pc.printf("t%d\n", ThorttleError);
- pc.printf("p%d\n", PedalError);
- pc.printf("B%d\n", BSPDError);
- pc.printf("s%d\n", Shutdowncircuit);
- i++;
- j++;
- k++;
- z++;
- e++;
- Pedal = i;
- Thorttle = i;
- RPM = j;
- Speed = k;
- Voltage = z;
- if(i == 255){
- i =0;
- }
- if(j == 10000){
- j =0;
- }
- if (k == 90){
- k=0;
- }
- if (z==24){
- z=0;
- }
- if (e == 1000){
- e = 0;
- if (Brake == 0){
- PedalError= 1;
- ThorttleError= 1;
- CANError= 1;
- Brake= 1;
- BSPDError= 1;
- Shutdowncircuit = 1;
-
- }
- else{
- PedalError= 0;
- ThorttleError= 0;
- CANError= 0;
- Brake= 0;
- BSPDError= 0;
- Shutdowncircuit = 0;
- }
-
- }
+ while(true) {
+ /// Test code ///
+ lcd.clearLine(1);
+ lcd.printf("Full Bright Test");
+ lcd.setBrightness(30);
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("Blink Test");
+ lcd.setCursor(2, 1);
+ lcd.printf("Blinking");
+ lcd.blink();
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("Clear Test");
+ wait(2);
+ lcd.clear();
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("New Char Test");
+ lcd.setCursor(2, 1);
+ lcd.createChar(1, smiley);
+ lcd.printCustomChar(1);
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("Cursor Test");
+ lcd.setCursor(2, 1);
+ lcd.cursor();
+ wait(3);
-
-
+ lcd.clearLine(1);
+ lcd.printf("Display Test");
+ lcd.noDisplay();
+ wait(2);
+ lcd.display();
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("Home Test");
+ lcd.setCursor(2, 1);
+ lcd.home();
+ lcd.printf("Got home");
+ wait(3);
+
+ lcd.leftToRight();
+ lcd.clearLine(1);
+ lcd.printf("LeftToRight Test");
+ wait(3);
- }
+ lcd.clearLine(1);
+ lcd.printf("noBlink Test");
+ lcd.setCursor(2, 1);
+ lcd.noBlink();
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("noCursor Test");
+ lcd.setCursor(2, 1);
+ lcd.noCursor();
+ wait(3);
+
+ lcd.rightToLeft();
+ lcd.clearLine(1);
+ lcd.printf("rightToLeft Test");
+ wait(3);
+
+ lcd.clearLine(1);
+ lcd.printf("Half Bright Test");
+ lcd.setBrightness(15);
+ wait(3);
+ }
}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialLCD.lib Thu Apr 22 10:47:19 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/fossum_13/code/SerialLCD/#96f055419f71