示例#1
0
__attribute__((no_instrument_function))  void not_main(void)
{

    unsigned int ra;

    serial_init();
    print_s("\n\rTesting SD CARD INITIALIZATION\n\r");
    sd_init();


   // list_root_directory();
    FILE *fd;
    fd = fopen("TORNADO.JPG");

    fwrite(fd,"Yaaayie",10);
    unsigned char *test = (unsigned char*)malloc(sizeof(unsigned char)*6);
    fread(fd,test,10);
    print_s("\n\rContents: ");
    for(int i=0;i<10;i++)
        print_ch(test[i]);


    free(test);
    free(fd);
    return;
}
示例#2
0
int _write(int file, char *ptr, int len)
{
    unsigned int ra;
    for(ra=0;ra<150;ra++)
        dummy(ra);
    for(ra=0;ra<len;ra++)
        print_ch(*ptr++);
    return len;
}
示例#3
0
void print_tree(ExpressionNode *tree)
{
    if (tree == NULL) {
        return;
    }
    print_tree(tree->Dbg_Left());
    std::cout << "[";
    print_ch(tree->Dbg_Str());
    std::cout << "]";
    print_tree(tree->Dbg_Right());
}
示例#4
0
// shows time - used when setting time
void show_time_setting(uint8_t hour, uint8_t min, uint8_t sec)
{
	dots = 0;
	uint8_t offset = 0;
	
	switch (digits) {
	case 8:
		offset = print_ch(' ', offset);
		offset = print_ch(' ', offset);
		// fall-through
	case 6:
		offset = print_digits(hour, offset);
		offset = print_ch('-', offset);
		offset = print_digits(min, offset);
		offset = print_ch(' ', offset);
		break;
	case 4:
		offset = print_digits(hour, offset);
		offset = print_digits(min, offset);		
	}
}
示例#5
0
void print_mid_line(int var_strlen_max[])
{
    int i, j;
    print_ch(LC);
    for (i = 0; i < VAR_NUM; i++)
    {
        for (j = 0; j < var_strlen_max[i]; j++)
        {
            print_ch(HL);
        }

        if (i == VAR_NUM -1){
            print_ch(RC);
        }
        else
        {
            print_ch(MC);
        }
    }
    printf("\n");
}
示例#6
0
void print_box_letters(char box_line[VAR_NUM][STR_BUFFER_SIZE], int var_strlen_max[], int all_bold)
{
    int i, j;

    print_ch(VL);
    for (i = 0; i < VAR_NUM; i++)
    {
        if (all_bold || i == 0)
        {
            printf(ANSI_COLOR_CYAN ANSI_FONT_BOLD"%s" ANSI_COLOR_RESET, box_line[i]);
        }
        else
        {
            if (i == 3)
            {
                if (strcmp(box_line[i], " online ") == 0)
                {
                    printf(ANSI_COLOR_GREEN ANSI_FONT_BOLD"%s" ANSI_COLOR_RESET, box_line[i]);
                }
                else
                {
                    printf(ANSI_COLOR_RED ANSI_FONT_BOLD"%s" ANSI_COLOR_RESET, box_line[i]);
                }
            }
            else
            {
                printf("%s", box_line[i]);
            }

        }

        for (j = 0; j < var_strlen_max[i] - strlen(box_line[i]); j++)
        {
            printf(" ");
        }
        print_ch(VL);
    }
    printf("\n");
}
示例#7
0
void title()
{
   //
   int* ptr;
   
   ptr = malloc(4);
   
   *ptr = 0x11223344;
   
   DEBUG_PRINTF("ptr = %#x\n", (u32)ptr);
   DEBUG_PRINTF("&obj_buffer = %#x\n",(u32)obj_buffer);
   
   u8 bytes[5] = { 0x11, 0x22, 0x33, 0x44, 0x55 };
   u16 halfwords[5] = { 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA };
   u32 words[3] = { 0x11223344, 0x55667788, 0x99AABBCC };
   
   DEBUG_PRINTF("&bytes = %#x\n", (u32)bytes);
   DEBUG_PRINTF("&halfwords = %#x\n", (u32)halfwords);
   DEBUG_PRINTF("&words = %#x\n", (u32)words);
   
   
   

   memcpy(vid_mem, titleBitmap, titleBitmapLen);
   
   REG_DISPCNT = DCNT_MODE3 | DCNT_BG2;
   
   char* h = "PRESS A TO CONTINUE\n";
   
   int x = 50, y = 100;
   int frame = 0;
   while(~key_hit(KEY_A))
   {
      key_poll();
      vid_vsync();
      
      if( frame & 1 && *h != 0)
      {
         print_ch(*h, x, y, 0x0000);
         x += 6;
         h ++;
         frame = 0;
      }
      
      frame ++;
      
      if(key_hit(KEY_A))
         break;
   }
}
示例#8
0
// shows time based on mode
// 4 digits: hour:min / sec
// 6 digits: hour:min:sec / hour-min
// 8 digits: hour:min:sec / hour-min-sec
void show_time(struct tm* t, bool _24h_clock, uint8_t mode)
{
	dots = 0;

	uint8_t offset = 0;
	uint8_t hour = _24h_clock ? t->hour : t->twelveHour;

	print_dots(mode, t->sec);

	if (mode == 0) { // normal display mode
		if (digits == 8) { // " HH.MM.SS "
			if (!_24h_clock && !t->am)
				offset = print_ch('P', offset);
			else
				offset = print_ch(' ', offset); 
			offset = print_hour(hour, offset, _24h_clock);  // wm
			offset = print_digits(t->min, offset);
			offset = print_digits(t->sec, offset);
			offset = print_ch(' ', offset);
		}
		else if (digits == 6) { // "HH.MM.SS"
			offset = print_hour(hour, offset, _24h_clock);  // wm
			offset = print_digits(t->min, offset);
			offset = print_digits(t->sec, offset);			
		}
		else { // HH.MM
			offset = print_hour(hour, offset, _24h_clock);  // wm
			offset = print_digits(t->min, offset);
		}
	}
	else if (mode == 1) { // extra display mode
		if (digits == 8) { // "HH-MM-SS"
			offset = print_digits(hour, offset);
			offset = print_ch('-', offset);
			offset = print_digits(t->min, offset);
			offset = print_ch('-', offset);
			offset = print_digits(t->sec, offset);
		}
		else if (digits == 6) { // " HH-MM"
			offset = print_digits(hour, offset);
			offset = print_ch('-', offset);
			offset = print_digits(t->min, offset);
			if (!_24h_clock && !t->am)
				offset = print_ch('P', offset);
			else
				offset = print_ch(' ', offset); 
		}
		else { // HH.MM
			if (_24h_clock) {
				offset = print_ch(' ', offset);
				offset = print_digits(t->sec, offset);
				offset = print_ch(' ', offset);
			}
			else {
				if (t->am)
					offset = print_ch('A', offset);
				else
					offset = print_ch('P', offset);

				offset = print_ch('M', offset);
				offset = print_digits(t->sec, offset);
			}
		}
	}
}
示例#9
0
void print_str(u8 *str)
{
	while (*str != '\0')
		print_ch(*str++);
}
示例#10
0
文件: printk.c 项目: sktwj/var
int printk(const char *fmt, ...)
{
	//上一次遍历到的字符是不是%,normal表示不是%,fmt表示是%。该标记决定了当前遍历到的字符是格式符还是正常字符
	enum {
		NORMAL, //非'%'
		FMT, //'%'
	} FMT_FLG;

	int count = 0; //统计最终打印的字符数量
	int cur_count = 0;

	FMT_FLG = NORMAL;

	va_list ap;
	va_start(ap, fmt);

	for (; *fmt; ++fmt) {
		switch (*fmt) {
		case '%':
			if (FMT_FLG == NORMAL) {
				FMT_FLG = FMT;
			} else { //连续两个%
				print_ch(*fmt);
				++count;
				FMT_FLG = NORMAL;
			}
			break;
		case 'c':
			//排除普通的字符
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
			} else {
				print_ch((char)va_arg(ap, int));
				FMT_FLG = NORMAL;
			}
			++count;
			break;
		case 's':
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
				++count;
			} else {
				char *str = va_arg(ap, char*);
				print_str(str);
				for (; *str; str++) {
					++count;
				}
				FMT_FLG = NORMAL;
			}
			break;
		case 'd':
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
				++count;
			} else {
				cur_count = itoa(va_arg(ap, int), 10, SIGNED);
				count += cur_count;
				FMT_FLG = NORMAL;
			}
			break;
		case 'u':
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
				++count;
			} else {
				cur_count = itoa(va_arg(ap, int), 10, UNSIGNED);
				count += cur_count;
				FMT_FLG = NORMAL;
			}
			break;
		case 'b':
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
				++count;
			} else {
				cur_count = itoa(va_arg(ap, int), 2, UNSIGNED);
				count += cur_count;
				FMT_FLG = NORMAL;
			}
			break;
		case 'x':
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
				++count;
			} else {
				cur_count = itoa(va_arg(ap, int), 16, UNSIGNED);
				count += cur_count;
				FMT_FLG = NORMAL;
			}
			break;
		default:
			if (FMT_FLG == NORMAL) {
				print_ch(*fmt);
				++count;
			} else {
				FMT_FLG = NORMAL;
			}
			break;
		}
	}

	va_end(ap);

	return count;
}