-
Notifications
You must be signed in to change notification settings - Fork 0
/
PIXMOB_EEPROM_flash2.bt
147 lines (129 loc) · 4.08 KB
/
PIXMOB_EEPROM_flash2.bt
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//------------------------------------------------
// PIXMOB EEPROM 24C02
//------------------------------------------------
typedef int bool;
#define true 1;
#define false 0;
//c++
typedef byte int8_t;
typedef int16 int16_t;
typedef int32 int32_t;
typedef int64 int64_t;
typedef int64 intptr_t;
typedef uchar uint8_t;
typedef uint16 uint16_t;
typedef uint32 uint32_t;
typedef uint64 uint64_t;
typedef uint64 uintptr_t;
long PaddingAlign(long num, int alignTo) {
return (num % alignTo == 0) ? 0 : alignTo - (num % alignTo);
}
bool AlignFS(int alignTo) {
local int b2skip = PaddingAlign(FTell(), alignTo);
FSkip(b2skip);
return true;
}
ubyte CalcCheckSum8(ubyte colA, ubyte colB, ubyte colC)
{
local ubyte output = (colA + colB + colC) & 0xFF;
return output;
}
typedef enum <byte>
{
IF_MODE = 0x0,
UNK_MODE = 0x1,
MEM_MODE = 0x11,
} PIX_CTRL_MODE;
typedef struct {
uint8_t control_bit0 : 1;
uint8_t control_bit1 : 1;
uint8_t control_bit2 : 1;
uint8_t control_bit3 : 1;
uint8_t control_bit4 : 1;
uint8_t control_bit5 : 1;
uint8_t control_bit6 : 1;
uint8_t control_bit7 : 1;
} _PIXMOB_CONTROL_REGISTER;
typedef struct {
uint8_t color_green; //<fgcolor=cBlack, bgcolor=0x00FF00>;
uint8_t color_red; //<fgcolor=cBlack, bgcolor=0x0000FF>;
uint8_t color_blue; //<fgcolor=cBlack, bgcolor=0xFF0000>;
uint8_t checksum <comment="checksum">; // ((color_green+color_red+color_blue) & 0xFF)
local uint8_t auto_calc_checksum = CalcCheckSum8(color_green, color_red, color_blue);
if (auto_calc_checksum == checksum)
{
//Printf("Col(%x,%x,%x) => [%x]\n", color_green, color_red, color_blue,
// auto_calc_checksum);
}
else
{
Printf("col @ location [0x%x] Checksum [%x] is wrong! Correct: [%x]\n",
(FTell() - 4), checksum, auto_calc_checksum);
}
} _PIXMOB_COLOR_Profile;
typedef struct {
_PIXMOB_CONTROL_REGISTER control_a;
uint8_t control_b;
uint8_t control_c;
uint8_t control_d;
PIX_CTRL_MODE control_e;
uint8_t control_f;
uint8_t control_g;
uint8_t control_h;
} _PIXMOB_EEPROM_CTRL_MAIN;
typedef struct {
_PIXMOB_EEPROM_CTRL_MAIN ctrl_main;
uint8_t color_profile_settings[8];
_PIXMOB_COLOR_Profile color1;
_PIXMOB_COLOR_Profile color2;
_PIXMOB_COLOR_Profile color3;
_PIXMOB_COLOR_Profile color4;
_PIXMOB_COLOR_Profile color5;
_PIXMOB_COLOR_Profile color6;
_PIXMOB_COLOR_Profile color7;
_PIXMOB_COLOR_Profile color8;
_PIXMOB_COLOR_Profile color9;
_PIXMOB_COLOR_Profile color10;
_PIXMOB_COLOR_Profile color11;
_PIXMOB_COLOR_Profile color12;
_PIXMOB_COLOR_Profile color13;
_PIXMOB_COLOR_Profile color14;
_PIXMOB_COLOR_Profile color15;
_PIXMOB_COLOR_Profile color16;
} _PIXMOB_MEM_SECTION_A;
typedef struct {
uint8_t cfg_memmode_col_green_value; //<fgcolor=cBlack, bgcolor=0x00FF00>;
uint8_t cfg_memmode_col_red_value; //<fgcolor=cBlack, bgcolor=0x0000FF>;
uint8_t cfg_memmode_col_blue_value; //<fgcolor=cBlack, bgcolor=0xFF0000>;
uint8_t cfg_attack_flow_timer;
uint8_t cfg_hold_timer; //How long to stay at that intensity before starting to dim
uint8_t cfg_release_timer; //How slow to fade from full intensity to dim
union
{
uint8_t cfg_profile_range;
struct
{
uint8_t high_end_profile_index : 4; // Bits [7:4]
uint8_t low_end_profile_index : 4; // Bits [3:0]
} cfg_profile_range_dissect;
} cfg_profile_range_u;
union
{
uint8_t cfg_mode_selector;
struct
{
uint8_t reserved_bits : 5; // Bits [7:3]
uint8_t mode_bits : 2; // Bits [2:1]
uint8_t another_reserved_bit : 1; // Bit [0]
} cfg_mode_selector_dissect;
} cfg_mode_selector_u;
} _PIXMOB_MEM_SECTION_B;
//These chips work in big Endian
BigEndian();
//local vars
local int64 fp = 0;
local int64 fileSize = FileSize();
local byte currentByte = 0;
FSeek(0);
_PIXMOB_MEM_SECTION_A mem_a;
_PIXMOB_MEM_SECTION_B eeprom_mem_config;