This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.text
86 lines (77 loc) · 2.39 KB
/
demo.text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Image demo for the TAP (Technology Access Platform)
*
* Copyright (C) 2016 TheLab.ms
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <font_ascii.h>
#include "main.h"
#define USER_DATA_SIZE 56
unsigned char user_data[USER_DATA_SIZE];
unsigned char text_data[] = " Hello, World! ";
void setup(void)
{
// This code is invoked once to initialize the demo...
}
void move_text_frame()
{
int time_offset = state.frame_sync % ((USER_DATA_SIZE - 1) * 8);
time_offset /= 2;
unsigned int row, col;
unsigned int col_offset = state.x_address * 8;
for (row = 0; row < 8; row++)
{
for (col = 0; col < 8; col++)
{
unsigned char brightness;
if (!(time_offset % 2)) /* even */
{
int string_index = (((time_offset / 2) + col_offset) + col) / 8;
int font_index = (((time_offset / 2) + col_offset) + col) % 8;
unsigned char row_byte = font_ascii[text_data[string_index]][row];
brightness = 20 * ((row_byte >> font_index) & 0x1);
}
else /* odd */
{
int string_index = (((time_offset / 2) + col_offset) + col) / 8;
int font_index = (((time_offset / 2) + col_offset) + col) % 8;
unsigned char row_byte = font_ascii[text_data[string_index]][row];
bool first_on = ((row_byte >> font_index) & 0x1);
string_index = (((time_offset / 2) + 1 + col_offset) + col) / 8;
font_index = (((time_offset / 2) + 1 + col_offset) + col) % 8;
row_byte = font_ascii[text_data[string_index]][row];
bool next_on = ((row_byte >> font_index) & 0x1);
if (first_on && next_on)
brightness = 20;
else if (first_on)
brightness = 3;
else if (next_on)
brightness = 3;
else
brightness = 0;
}
display_buffer[row][(col * COL_SIZE) + 0] = brightness;
display_buffer[row][(col * COL_SIZE) + 1] = brightness;
display_buffer[row][(col * COL_SIZE) + 2] = brightness;
}
}
}
void loop(void)
{
static int counter = 0;
if (counter++ <= 3)
{
__delay_cycles(1000); // so transition frame is not longer
return;
}
counter = 0;
move_text_frame();
}