This simple program will test the functionality of the m3pi\'s usb port by reading a file on a usb flash drive (called YourText.txt) and printing it to the m3pi\'s inbuilt LCD display.
main.cpp
00001 #include "mbed.h" 00002 #include "m3pi.h" 00003 #include "MSCFileSystem.h" 00004 00005 DigitalOut myled(LED1); 00006 m3pi m3pi; 00007 MSCFileSystem msc("usb"); 00008 00009 //The m3pi can have a maximum of 8 charicters on a row of it's display, so logically that is all we need to accomedate 00010 char YourText[8]; 00011 00012 int main() { 00013 //set the file you want to open to /usb/YourFile.txt and we want to read it, so fopen needs 'r' 00014 FILE *YourFile = fopen("/usb/YourFile.txt", "r"); 00015 if (YourFile == NULL) { 00016 //if your file isnt there, turn an led on and do nothing else 00017 myled = 1; 00018 while (1) {} 00019 } 00020 //scan untill you hit then end of the document and put everything in YourText as a string 00021 while (!feof(YourFile)) { 00022 fscanf (YourFile, "%s", YourText); 00023 } 00024 m3pi.cls(); 00025 //and print your message! 00026 m3pi.printf("%s", YourText); 00027 }
Generated on Wed Jul 13 2022 17:14:52 by 1.7.2