⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainbackup.c

📁 this is a routine to do int2bin printing
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <SDL/SDL.h>unsigned long *framebuffer;SDL_Surface *screen;void fb(){screen=SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);framebuffer=(unsigned long *)screen->pixels;}void prints(int cx, int cy, char* text) {    extern unsigned char font[];    int x, y;    char c;    while (*text) {        for (y = 0; y<=16; y++) {            for (x = 0; x<=8; x++) {                if(font[(*text)*16+y] & (1<<(8-x))) c = 0xff; else c = 0;                framebuffer[(cy*16+y)*640+(cx*8+x)] = c;            }        }        cx++;        text++;    }}unsigned long int2bin(int a){unsigned char *c;unsigned char buffer[40];int clrcnt;for(clrcnt=0;clrcnt<=31;clrcnt++){buffer[clrcnt]=0;}int cnt;for(cnt=0;cnt<=30;cnt++){if(a & (1<<(30-cnt))) c='1'; else c='0';buffer[cnt]=c;}return buffer;}doit(){SDL_Flip(screen);unsigned long *P_GPIO=(unsigned long *)0x0804869c;//prints(1, 2, "---DEBUG GPIO---");prints(1, 3, int2bin(*P_GPIO));//prints(31,3,"|");doit();}int main(){fb();doit();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -