![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Tests of linear stage
Dependencies: mbed C12832 app-board-Potentiometer-LCD USBDevice
main.cpp@0:abb6184fc121, 2014-12-15 (annotated)
- Committer:
- fchoco
- Date:
- Mon Dec 15 06:07:19 2014 +0000
- Revision:
- 0:abb6184fc121
- Child:
- 1:8abaa664f287
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fchoco | 0:abb6184fc121 | 1 | #include "mbed.h" |
fchoco | 0:abb6184fc121 | 2 | #include "C12832.h" |
fchoco | 0:abb6184fc121 | 3 | |
fchoco | 0:abb6184fc121 | 4 | AnalogIn pot1(p19); |
fchoco | 0:abb6184fc121 | 5 | AnalogIn pot2(p20); |
fchoco | 0:abb6184fc121 | 6 | |
fchoco | 0:abb6184fc121 | 7 | C12832 lcd(p5, p7, p6, p8, p11); |
fchoco | 0:abb6184fc121 | 8 | |
fchoco | 0:abb6184fc121 | 9 | int main() |
fchoco | 0:abb6184fc121 | 10 | { |
fchoco | 0:abb6184fc121 | 11 | int p1, p2; |
fchoco | 0:abb6184fc121 | 12 | |
fchoco | 0:abb6184fc121 | 13 | lcd.set_auto_up(0); |
fchoco | 0:abb6184fc121 | 14 | |
fchoco | 0:abb6184fc121 | 15 | while(true) { |
fchoco | 0:abb6184fc121 | 16 | p1 = pot1.read_u16(); |
fchoco | 0:abb6184fc121 | 17 | p2 = pot2.read_u16(); |
fchoco | 0:abb6184fc121 | 18 | |
fchoco | 0:abb6184fc121 | 19 | lcd.locate(0, 0); |
fchoco | 0:abb6184fc121 | 20 | lcd.printf("Pot1 : %04X ", p1); |
fchoco | 0:abb6184fc121 | 21 | p1 = p1 * lcd.width() / 0xffff; |
fchoco | 0:abb6184fc121 | 22 | lcd.fillrect(0, 9, p1, 14, 1); |
fchoco | 0:abb6184fc121 | 23 | lcd.fillrect(p1 + 1, 9, lcd.width() - 1, 14, 0); |
fchoco | 0:abb6184fc121 | 24 | lcd.locate(0, 16); |
fchoco | 0:abb6184fc121 | 25 | |
fchoco | 0:abb6184fc121 | 26 | lcd.printf("Pot2 : %04X ", p2); |
fchoco | 0:abb6184fc121 | 27 | p2 = p2 * lcd.width() / 0xffff; |
fchoco | 0:abb6184fc121 | 28 | lcd.fillrect(0, 25, p2, 30, 1); |
fchoco | 0:abb6184fc121 | 29 | lcd.fillrect(p2 + 1, 25, lcd.width(), 30, 0); |
fchoco | 0:abb6184fc121 | 30 | |
fchoco | 0:abb6184fc121 | 31 | lcd.copy_to_lcd(); |
fchoco | 0:abb6184fc121 | 32 | |
fchoco | 0:abb6184fc121 | 33 | wait(0.1); |
fchoco | 0:abb6184fc121 | 34 | } |
fchoco | 0:abb6184fc121 | 35 | } |