Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 3431|回復: 0

arduino 16*16怎麼跑出完整字串

[複製鏈接]
發表於 2012-12-13 15:03:18 | 顯示全部樓層 |閱讀模式
arduino 16*16 的面板要怎麼連續跑出完整字串....目前可以跑中文字了可是只能單一個字一個字這樣跑,
有辦法可以一連串一起跑出來嗎!?
中文字的部分是用土法煉鋼的方式慢慢算出來的

/*****************************************************************************
* Copyright: ChengDu Geeker Tech. Co., Ltd.
* File name: hello_matrix.pde
* Description: test the function of rgb matrix
* Author: wanghui_CD
* Version: V1.0
* Date: 2012.06.21
* History: none
*****************************************************************************/
#include <rgb_matrix.h>
#include <SPI.h>

unsigned long time=0;
unsigned int tick_100ms = 0;
unsigned char counter=0;

#define N_X 2
#define N_Y 2

/*
//Interface shield ShiftOut connector
#define DATA_PIN 9
#define CLK_PIN 3
*/
//Hardware SPI
#define DATA_PIN 11
#define CLK_PIN 13

#define LATCH_PIN 8

rgb_matrix M = rgb_matrix(N_X, N_Y, DATA_PIN, CLK_PIN, LATCH_PIN);
int put_HZ(int16_t x, int16_t y, const char p[], const char a[]);
unsigned char cmd[50]={0},cmd_num=0;
const char p[] =
{

0x00,0x08,0x08,0x08,0x09,0x0b,0x1E,0x3C,
0x6E,0x0b,0x09,0x08,0x08,0x08,0x00,0x00,
0x00,0x20,0x60,0xc0,0x80,0x00,0x00,0x00,
0x00,0x00,0x80,0xc0,0x60,0x20,0x00,0x00,

};
void setup()
{
Serial.begin(115200);
delay(200);
}

/*************************************************************************
* Description:
* display callback function
* Receive AT comand via serial,and then run the right comand.
* This function can be run in sweep interval.
* Reduce delay time at function tail if screen blink.
* Increase delay time at function tail if screen shows a double image.
* Param: none
* Retval: none
**************************************************************************/
void hook(void)
{
int i = 0;
if((++counter)%10 == 0)
{
if(millis() - time >= 100)
{
time = millis();
tick_100ms ++;
if(tick_100ms%2 == 0)
{
}
if(tick_100ms%5 == 0)
{
}
if(tick_100ms%10 == 0)
{
M.move(LEFT,1,TOP_LAYER); //頂層(圖層0)每秒左移一位
}
if(tick_100ms%20 == 0)
{
M.move(RIGHT,1,TOP_LAYER+1); //圖層1每2秒右移一位
}
if(tick_100ms%50 == 0)
{
}
}
}
if(Serial.available())
{
cmd[cmd_num++] = Serial.read();
if((cmd_num>=2) && (cmd[cmd_num-1] == 0x0a) && (cmd[cmd_num-2] == 0x0d))
{
M.at_cmd(cmd);
cmd_num = 0;
}
}
}

/*************************************************************************************
* Description:
* loop function
* Display function must be called.
* If you wanna do something after display be called,
* you should give display function a parameter which is a pointer to a function.
* Param: none
* Retval: none
**************************************************************************************/
void loop()
{
int tmp,i;
M.add_layer();
M.put_HZ(0,0,p,COVER,RED,TOP_LAYER);
M.display(hook);
}

您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-3-29 22:49 , Processed in 0.212723 second(s), 11 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表