/
print_memory.ino
49 lines (41 loc) · 1.04 KB
/
print_memory.ino
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
#include "Adafruit_Thermal.h"
#include "SoftwareSerial.h"
#include "methods.h"
/**
* Declare which pins to communicate to the printer over
*/
int printer_RX_Pin = 5; // green wire
int printer_TX_Pin = 6; // yellow wire
/**
* Initialize the thermal printer
*/
Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);
void setup(){
initChars();
printer.begin();
node *root = setList("LinkedList NYC", 14);
printer.printBitmap(4*8, 2000/4, (uint8_t*)(((int)root)%4), false);
printer.feed(2);
}
uint8_t getDstI(uint8_t i){
return i/8*4 + 3 - ((i%8)/2);
}
node * setList(char *text, uint8_t length){
node *curr = new node;
uint8_t *src = ascii[(*(text))-startChar];
for(uint8_t i = 0; i < 4*4*4*2; i++){
curr->arr[getDstI(i)] >>= 4;
if ((*(text)) != ' ' &&
(i < 4*4*3*2) &&
(((*(src+(i/(4*8)))) >> (i%8)) & 1) == 1){
curr->arr[getDstI(i)] |= 0xf0;
} else {
curr->arr[getDstI(i)] &= 0x0f;
}
}
if (length > 1){
curr->next = setList(text + 1, length - 1);
}
return curr;
}
void loop(){}