forked from akafugu/VFDDeluxe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flw.h
59 lines (47 loc) · 1.48 KB
/
flw.h
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
/*
* Four Letter Word Generator
* (C) 2012-13 Akafugu Corporation
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* 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.
*
*/
#ifndef FLW_H__
#define FLW_H__
#include <inttypes.h>
#include <stdbool.h>
// FLW level
#define FLW_OFF 0 // disabled
#define FLW_ON 1 // on (cencored)
#define FLW_FULL 2 // on (uncensored)
class FourLetterWord
{
private:
bool m_censored;
unsigned long m_offset;
char m_current_word[6];
uint32_t m_lfsr;
uint32_t randomize();
void rot13(char* w);
bool binary_search(const char *key, int imin, int imax);
uint8_t read_byte(int device, unsigned int addr);
void read_buffer(int device, unsigned int addr, uint8_t *buffer, int length);
char* get_word_censored();
char* get_word_uncensored();
public:
FourLetterWord() :
m_censored(true),
m_offset(0),
m_lfsr(0xbeefcace) {}
void begin(uint32_t seed = 0xbeefcace, bool censored = true);
void setCensored(bool c) { m_censored = c; }
bool has_eeprom();
char* get_word();
};
#endif