~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/surfaces/tranzport/lcd.cc

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2006 Paul Davis 
 
3
 *   Copyright (C) 2007 Michael Taht
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 *  
 
19
 *   */
 
20
 
 
21
#include <tranzport_control_protocol.h>
 
22
 
 
23
// doing these functions made me realize that screen_invalid should be lcd_isdamaged FIXME soon
 
24
 
 
25
bool TranzportControlProtocol::lcd_damage() 
 
26
{
 
27
        screen_invalidate();
 
28
        return true;
 
29
}
 
30
 
 
31
bool TranzportControlProtocol::lcd_damage (int row, int col, int length)
 
32
{
 
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;
 
38
        return true;
 
39
}
 
40
 
 
41
// Still working on the layering, arguably screen_invalid should be lcd_invalid
 
42
// or vice versa
 
43
 
 
44
bool TranzportControlProtocol::lcd_isdamaged () 
 
45
{
 
46
        if(screen_invalid.any()) {
 
47
#if DEBUG_TRANZPORT > 5 
 
48
                printf("LCD is damaged somewhere, should redraw it\n");
 
49
#endif
 
50
                return true;
 
51
        }
 
52
        return false;
 
53
}
 
54
 
 
55
bool TranzportControlProtocol::lcd_isdamaged (int row, int col, int length)
 
56
{
 
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;
 
62
        if(mask.any()) {
 
63
#if DEBUG_TRANZPORT > 5 
 
64
                printf("row: %d,col: %d is damaged, should redraw it\n", row,col);
 
65
#endif
 
66
                return true;
 
67
        }
 
68
        return false; 
 
69
}
 
70
 
 
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....
 
75
 
 
76
void
 
77
TranzportControlProtocol::lcd_clear ()
 
78
{
 
79
 
 
80
}
 
81
 
 
82
// These lcd commands are not universally used yet and may drop out of the api
 
83
 
 
84
int
 
85
TranzportControlProtocol::lcd_flush ()
 
86
{
 
87
        return 0; 
 
88
}
 
89
 
 
90
int 
 
91
TranzportControlProtocol::lcd_write(uint8_t* cmd, uint32_t timeout_override)
 
92
{
 
93
        int result;
 
94
#if (DEBUG_TRANZPORT_SCREEN > 0)
 
95
        printf("VALID  : %s\n", (screen_invalid.to_string()).c_str()); 
 
96
#endif
 
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]); 
 
101
#endif
 
102
        }
 
103
        return result;
 
104
}
 
105
 
 
106
void 
 
107
TranzportControlProtocol::lcd_fill (uint8_t fill_char) 
 
108
{
 
109
}
 
110
 
 
111
void 
 
112
TranzportControlProtocol::lcd_print (int row, int col, const char* text) 
 
113
{
 
114
        print(row,col,text);
 
115
}
 
116
 
 
117
void TranzportControlProtocol::lcd_print_noretry (int row, int col, const char* text)
 
118
{
 
119
        print(row,col,text);
 
120
}