AD-128160-UART制御用のライブラリ http://mbed.org/users/nucho/libraries/AD128160/m24mml を試してみるシンプルなプログラムです。 === image === {{http://farm8.staticflickr.com/7028/6496821539_333a08b551.jpg}} === circuit === {{http://farm8.staticflickr.com/7164/6498120233_a004e4fe29.jpg}}
main.cpp@0:4e906b12a024, 2011-12-12 (annotated)
- Committer:
- nucho
- Date:
- Mon Dec 12 03:09:32 2011 +0000
- Revision:
- 0:4e906b12a024
- Child:
- 1:edf1eade7570
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:4e906b12a024 | 1 | #include "mbed.h" |
nucho | 0:4e906b12a024 | 2 | #include "AD128160.h" |
nucho | 0:4e906b12a024 | 3 | |
nucho | 0:4e906b12a024 | 4 | AD128160 lcd(p9,p20); |
nucho | 0:4e906b12a024 | 5 | |
nucho | 0:4e906b12a024 | 6 | int rgb565(int r, int g,int b) |
nucho | 0:4e906b12a024 | 7 | { |
nucho | 0:4e906b12a024 | 8 | int rgb; |
nucho | 0:4e906b12a024 | 9 | |
nucho | 0:4e906b12a024 | 10 | rgb = (r & 0xF8) << 8; /* RRRRR----------- */ |
nucho | 0:4e906b12a024 | 11 | rgb |= (g & 0xFC) << 3; /* -----GGGGGG----- */ |
nucho | 0:4e906b12a024 | 12 | rgb |= b >> 3; /* -----------BBBBB */ |
nucho | 0:4e906b12a024 | 13 | |
nucho | 0:4e906b12a024 | 14 | return rgb; |
nucho | 0:4e906b12a024 | 15 | } |
nucho | 0:4e906b12a024 | 16 | |
nucho | 0:4e906b12a024 | 17 | int main() { |
nucho | 0:4e906b12a024 | 18 | lcd.backgroudColor(rgb565(255,0,0)); |
nucho | 0:4e906b12a024 | 19 | lcd.locate(2,lcd.rows()/2); |
nucho | 0:4e906b12a024 | 20 | lcd.printf("Hello World!\n"); |
nucho | 0:4e906b12a024 | 21 | |
nucho | 0:4e906b12a024 | 22 | lcd.color(rgb565(0,255,0)); |
nucho | 0:4e906b12a024 | 23 | lcd.box(12,76,116,100,0); |
nucho | 0:4e906b12a024 | 24 | lcd.box(8,120,124,146,1); |
nucho | 0:4e906b12a024 | 25 | |
nucho | 0:4e906b12a024 | 26 | lcd.color(rgb565(255,0,0)); |
nucho | 0:4e906b12a024 | 27 | lcd.circle(16,40,16,0); |
nucho | 0:4e906b12a024 | 28 | lcd.circle(48,40,16,1); |
nucho | 0:4e906b12a024 | 29 | lcd.circle(80,40,16,1); |
nucho | 0:4e906b12a024 | 30 | lcd.circle(112,40,16,0); |
nucho | 0:4e906b12a024 | 31 | } |