test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Converter.cpp Source File

Converter.cpp

00001 #include "convert.h"
00002 #include "models.h"
00003 #include "point.h"
00004 #include "C12832_lcd.h" 
00005 #include <math.h>
00006 
00007 int pow(int x, int y){
00008     int ans = 1;
00009     for(int i = 0; i < y; i++){
00010         ans *= x;
00011     }
00012     return ans;   
00013 }
00014 
00015 int binary(int bina){
00016     int ans = 0;
00017     for (int i = 0; bina>0 ; i++)
00018     {
00019         ans = ans+(bina%2)*pow(10,i);
00020         bina = bina/2;
00021     }
00022     return ans;
00023 }
00024 
00025 Bitmap Converter::convert(int map[][LCD_X]){
00026     int len = LCD_Y*LCD_X/CHAR_SIZE;
00027     int count = 0;
00028     int tmp = 0;
00029     char char_map[len];
00030     for(int i = 0; i < len; i++ ){
00031         char_map[i] = 0;
00032     }
00033     
00034     for(int i = 0; i < LCD_Y; i++){
00035         for(int j = 0; j < LCD_X; j++){
00036             int index = (i*LCD_X + j)/CHAR_SIZE;
00037             char_map[index] |= map[i][j] << ((CHAR_SIZE - 1) - (i*LCD_X + j) % CHAR_SIZE);   
00038         }
00039     }
00040 
00041     //return char_map;
00042     Bitmap bitmap_converted = {
00043         LCD_X,
00044         LCD_Y,
00045         LCD_X/CHAR_SIZE,
00046         char_map,
00047     };
00048     return bitmap_converted;
00049 }
00050 
00051 
00052