test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
Converter.cpp@63:4c22abbe4727, 2016-12-16 (annotated)
- Committer:
- kaku_jyoko
- Date:
- Fri Dec 16 13:52:36 2016 +0000
- Revision:
- 63:4c22abbe4727
- Parent:
- 40:ec5c1b305b9a
remove led lump
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
th_mbed | 23:33d7efd62537 | 1 | #include "convert.h" |
th_mbed | 23:33d7efd62537 | 2 | #include "models.h" |
th_mbed | 23:33d7efd62537 | 3 | #include "point.h" |
pypy_o8o | 25:a08a1f5fbb6a | 4 | #include "C12832_lcd.h" |
th_mbed | 36:b88fa8ff0be9 | 5 | #include <math.h> |
th_mbed | 23:33d7efd62537 | 6 | |
kaku_jyoko | 39:e8d6dd3c75c7 | 7 | int pow(int x, int y){ |
kaku_jyoko | 39:e8d6dd3c75c7 | 8 | int ans = 1; |
kaku_jyoko | 39:e8d6dd3c75c7 | 9 | for(int i = 0; i < y; i++){ |
kaku_jyoko | 39:e8d6dd3c75c7 | 10 | ans *= x; |
kaku_jyoko | 39:e8d6dd3c75c7 | 11 | } |
kaku_jyoko | 39:e8d6dd3c75c7 | 12 | return ans; |
kaku_jyoko | 39:e8d6dd3c75c7 | 13 | } |
kaku_jyoko | 39:e8d6dd3c75c7 | 14 | |
kaku_jyoko | 39:e8d6dd3c75c7 | 15 | int binary(int bina){ |
kaku_jyoko | 39:e8d6dd3c75c7 | 16 | int ans = 0; |
kaku_jyoko | 39:e8d6dd3c75c7 | 17 | for (int i = 0; bina>0 ; i++) |
kaku_jyoko | 39:e8d6dd3c75c7 | 18 | { |
kaku_jyoko | 39:e8d6dd3c75c7 | 19 | ans = ans+(bina%2)*pow(10,i); |
kaku_jyoko | 39:e8d6dd3c75c7 | 20 | bina = bina/2; |
kaku_jyoko | 39:e8d6dd3c75c7 | 21 | } |
kaku_jyoko | 39:e8d6dd3c75c7 | 22 | return ans; |
kaku_jyoko | 39:e8d6dd3c75c7 | 23 | } |
kaku_jyoko | 39:e8d6dd3c75c7 | 24 | |
kaku_jyoko | 39:e8d6dd3c75c7 | 25 | Bitmap Converter::convert(int map[][LCD_X]){ |
th_mbed | 27:afdaee781efa | 26 | int len = LCD_Y*LCD_X/CHAR_SIZE; |
th_mbed | 36:b88fa8ff0be9 | 27 | int count = 0; |
th_mbed | 36:b88fa8ff0be9 | 28 | int tmp = 0; |
th_mbed | 27:afdaee781efa | 29 | char char_map[len]; |
th_mbed | 27:afdaee781efa | 30 | for(int i = 0; i < len; i++ ){ |
th_mbed | 27:afdaee781efa | 31 | char_map[i] = 0; |
th_mbed | 27:afdaee781efa | 32 | } |
kaku_jyoko | 39:e8d6dd3c75c7 | 33 | |
th_mbed | 23:33d7efd62537 | 34 | for(int i = 0; i < LCD_Y; i++){ |
th_mbed | 23:33d7efd62537 | 35 | for(int j = 0; j < LCD_X; j++){ |
th_mbed | 36:b88fa8ff0be9 | 36 | int index = (i*LCD_X + j)/CHAR_SIZE; |
kaku_jyoko | 39:e8d6dd3c75c7 | 37 | char_map[index] |= map[i][j] << ((CHAR_SIZE - 1) - (i*LCD_X + j) % CHAR_SIZE); |
th_mbed | 23:33d7efd62537 | 38 | } |
th_mbed | 23:33d7efd62537 | 39 | } |
kaku_jyoko | 40:ec5c1b305b9a | 40 | |
th_mbed | 36:b88fa8ff0be9 | 41 | //return char_map; |
pypy_o8o | 25:a08a1f5fbb6a | 42 | Bitmap bitmap_converted = { |
th_mbed | 27:afdaee781efa | 43 | LCD_X, |
th_mbed | 27:afdaee781efa | 44 | LCD_Y, |
th_mbed | 27:afdaee781efa | 45 | LCD_X/CHAR_SIZE, |
th_mbed | 27:afdaee781efa | 46 | char_map, |
th_mbed | 27:afdaee781efa | 47 | }; |
kaku_jyoko | 39:e8d6dd3c75c7 | 48 | return bitmap_converted; |
pypy_o8o | 25:a08a1f5fbb6a | 49 | } |
kaku_jyoko | 39:e8d6dd3c75c7 | 50 | |
kaku_jyoko | 39:e8d6dd3c75c7 | 51 | |
kaku_jyoko | 39:e8d6dd3c75c7 | 52 |