![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
The MBED firmware used on the Chipin sorter, developed over 12 weeks for a 3rd year university systems project. Chipin is a token sorter, it sorts tokens by colours and dispenses them to order through an online booking system and card reader. This program interfaces with an FPGA, PC and LCD screen to control the sorter. The sorter has an operation mode where it can process orders when a card is entered into the machine. There is also a maintenance mode where the device responds to maintenance instructions such as 'dispense all'. More information at http://www.ionsystems.uk/
Dependencies: MCP23017 TCS3472_I2C WattBob_TextLCD mbed-rtos mbed
mbedStorage.h@24:8868101d01d0, 2014-12-03 (annotated)
- Committer:
- IonSystems
- Date:
- Wed Dec 03 17:49:41 2014 +0000
- Revision:
- 24:8868101d01d0
- Parent:
- 23:f9e7e64784be
- Child:
- 27:47a7bc902587
Commented the .h files from top to bottom, got half way through FPGAcomms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IonSystems | 6:e64796f1f384 | 1 | #include "mbed.h" |
IonSystems | 23:f9e7e64784be | 2 | bool logEnable = false; |
IonSystems | 6:e64796f1f384 | 3 | LocalFileSystem local("local"); |
IonSystems | 23:f9e7e64784be | 4 | void writeFile(int r, int g, int b, int re) |
IonSystems | 23:f9e7e64784be | 5 | { |
IonSystems | 23:f9e7e64784be | 6 | |
IonSystems | 24:8868101d01d0 | 7 | FILE* file = fopen("/local/df.txt","w"); // open file |
IonSystems | 23:f9e7e64784be | 8 | if(r >= 0) { |
IonSystems | 23:f9e7e64784be | 9 | fputc(r, file); // put char (data value) into file |
IonSystems | 23:f9e7e64784be | 10 | } else { |
IonSystems | 23:f9e7e64784be | 11 | fputc(0, file); |
IonSystems | 23:f9e7e64784be | 12 | } |
IonSystems | 23:f9e7e64784be | 13 | if(g >= 0) { |
IonSystems | 23:f9e7e64784be | 14 | fputc(g, file); // put char (data value) into file |
IonSystems | 23:f9e7e64784be | 15 | } else { |
IonSystems | 23:f9e7e64784be | 16 | fputc(0, file); |
IonSystems | 12:814a8fdbb6f7 | 17 | } |
IonSystems | 23:f9e7e64784be | 18 | if(b >= 0) { |
IonSystems | 23:f9e7e64784be | 19 | fputc(b, file); // put char (data value) into file |
IonSystems | 23:f9e7e64784be | 20 | } else { |
IonSystems | 23:f9e7e64784be | 21 | fputc(0, file); |
IonSystems | 23:f9e7e64784be | 22 | } |
IonSystems | 23:f9e7e64784be | 23 | if(re >= 0) { |
IonSystems | 23:f9e7e64784be | 24 | fputc(re, file); // put char (data value) into file |
IonSystems | 23:f9e7e64784be | 25 | } else { |
IonSystems | 23:f9e7e64784be | 26 | fputc(0, file); |
IonSystems | 23:f9e7e64784be | 27 | } |
IonSystems | 23:f9e7e64784be | 28 | fclose(file); // close file |
IonSystems | 23:f9e7e64784be | 29 | |
IonSystems | 10:8c0696b99692 | 30 | } |
IonSystems | 23:f9e7e64784be | 31 | |
IonSystems | 23:f9e7e64784be | 32 | int readFile(int index) |
IonSystems | 23:f9e7e64784be | 33 | { |
IonSystems | 24:8868101d01d0 | 34 | FILE* file = fopen ("/local/df.txt","r"); // open file for reading |
IonSystems | 20:6de191ac7ff3 | 35 | int read_var = 0; |
IonSystems | 23:f9e7e64784be | 36 | for(int i = 0; i <= index; i++) { |
IonSystems | 10:8c0696b99692 | 37 | read_var = fgetc(file); // read data value |
IonSystems | 6:e64796f1f384 | 38 | } |
IonSystems | 10:8c0696b99692 | 39 | fclose(file); // close file |
IonSystems | 23:f9e7e64784be | 40 | return read_var; |
IonSystems | 10:8c0696b99692 | 41 | } |
IonSystems | 10:8c0696b99692 | 42 | |
IonSystems | 23:f9e7e64784be | 43 | void log(char* text) |
IonSystems | 23:f9e7e64784be | 44 | { |
IonSystems | 23:f9e7e64784be | 45 | if(logEnable) { |
IonSystems | 23:f9e7e64784be | 46 | FILE* file = fopen ("/local/log.txt", "a"); |
IonSystems | 10:8c0696b99692 | 47 | fputs(text, file); |
IonSystems | 10:8c0696b99692 | 48 | fputs("\r\n", file); |
IonSystems | 10:8c0696b99692 | 49 | fclose(file); |
IonSystems | 23:f9e7e64784be | 50 | } |
IonSystems | 10:8c0696b99692 | 51 | } |
IonSystems | 10:8c0696b99692 | 52 | |
IonSystems | 23:f9e7e64784be | 53 | void clearLog() |
IonSystems | 23:f9e7e64784be | 54 | { |
IonSystems | 10:8c0696b99692 | 55 | FILE* file = fopen ("/local/log.txt", "w"); |
IonSystems | 23:f9e7e64784be | 56 | fclose(file); |
IonSystems | 10:8c0696b99692 | 57 | } |