2
* Copyright (C) 2006 Paul Davis
3
* Copyright (C) 2007 Michael Taht
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
#include <tranzport_control_protocol.h>
23
// doing these functions made me realize that screen_invalid should be lcd_isdamaged FIXME soon
25
bool TranzportControlProtocol::lcd_damage()
31
bool TranzportControlProtocol::lcd_damage (int row, int col, int length)
33
std::bitset<ROWS*COLUMNS> mask1(0);
34
// there's an intrinsic to do this fast, darn it, or I'm just sleepy
35
for (int i = 0; i < length; i++) { mask1[i] = 1; }
36
std::bitset<ROWS*COLUMNS> mask(mask1 << (row*COLUMNS+col));
37
screen_invalid |= mask;
41
// Still working on the layering, arguably screen_invalid should be lcd_invalid
44
bool TranzportControlProtocol::lcd_isdamaged ()
46
if(screen_invalid.any()) {
47
#if DEBUG_TRANZPORT > 5
48
printf("LCD is damaged somewhere, should redraw it\n");
55
bool TranzportControlProtocol::lcd_isdamaged (int row, int col, int length)
57
// there's an intrinsic to do this fast, darn it
58
std::bitset<ROWS*COLUMNS> mask1(0);
59
for (int i = 0; i < length; i++) { mask1[i] = 1; }
60
std::bitset<ROWS*COLUMNS> mask(mask1 << (row*COLUMNS+col));
61
mask &= screen_invalid;
63
#if DEBUG_TRANZPORT > 5
64
printf("row: %d,col: %d is damaged, should redraw it\n", row,col);
71
// lcd_clear would be a separate function for a smart display
72
// here it does nothing, but for the sake of completeness it should
73
// probably write the lcd, and while I'm on the topic it should probably
74
// take a row, col, length argument....
77
TranzportControlProtocol::lcd_clear ()
82
// These lcd commands are not universally used yet and may drop out of the api
85
TranzportControlProtocol::lcd_flush ()
91
TranzportControlProtocol::lcd_write(uint8_t* cmd, uint32_t timeout_override)
94
#if (DEBUG_TRANZPORT_SCREEN > 0)
95
printf("VALID : %s\n", (screen_invalid.to_string()).c_str());
97
if ((result = write(cmd,timeout_override))) {
98
#if DEBUG_TRANZPORT > 4
99
printf("usb screen update failed for some reason... why? \nresult, cmd and data were %d %02x %02x %02x %02x %02x %02x %02x %02x\n",
100
result, cmd[0],cmd[1],cmd[2], cmd[3], cmd[4], cmd[5],cmd[6],cmd[7]);
107
TranzportControlProtocol::lcd_fill (uint8_t fill_char)
112
TranzportControlProtocol::lcd_print (int row, int col, const char* text)
117
void TranzportControlProtocol::lcd_print_noretry (int row, int col, const char* text)