Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
c90aecea
Commit
c90aecea
authored
Jul 25, 2014
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code formatting.
parent
8e7d03c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
lcd.c
sw/common/drivers/lcd.c
+10
-6
lcd.h
sw/common/drivers/lcd.h
+4
-0
No files found.
sw/common/drivers/lcd.c
View file @
c90aecea
...
...
@@ -20,6 +20,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief LS013B7DH03 LCD driver
*/
#include "lcd.h"
#include <em_cmu.h>
#include <em_usart.h>
...
...
@@ -27,7 +31,7 @@
#include <udelay.h>
// Framebuffer - pixels are stored as consecutive rows
static
uint8_t
buffer
[
LCD_WIDTH
/
8
*
LCD_HEIGHT
];
static
uint8_t
buffer
[
LCD_WIDTH
/
8
*
LCD_HEIGHT
];
static
void
spi_init
(
void
)
{
...
...
@@ -40,7 +44,7 @@ static void spi_init(void)
LCD_SPI_UNIT
->
ROUTE
=
(
USART_ROUTE_CLKPEN
|
USART_ROUTE_TXPEN
|
LCD_SPI_LOCATION
);
}
static
void
spi_transmit
(
uint8_t
*
data
,
uint8_t
length
)
static
void
spi_transmit
(
uint8_t
*
data
,
uint8_t
length
)
{
while
(
length
>
0
)
{
...
...
@@ -178,7 +182,7 @@ void lcd_update(void)
// TODO use DMA
uint16_t
cmd
;
uint8_t
i
;
uint8_t
*
p
=
(
uint8_t
*
)
buffer
;
uint8_t
*
p
=
(
uint8_t
*
)
buffer
;
GPIO_PinOutSet
(
LCD_PORT_SCS
,
LCD_PIN_SCS
);
timer_delay
(
6
);
...
...
@@ -206,7 +210,7 @@ void lcd_update(void)
GPIO_PinOutClear
(
LCD_PORT_SCS
,
LCD_PIN_SCS
);
}
void
lcd_set_pixel
(
uint
16_t
x
,
uint16
_t
y
,
uint8_t
value
)
void
lcd_set_pixel
(
uint
8_t
x
,
uint8
_t
y
,
uint8_t
value
)
{
uint8_t
mask
=
1
<<
(
x
&
0x07
);
// == 1 << (x % 8)
uint16_t
offset
=
(
y
*
LCD_WIDTH
>>
3
)
+
(
x
>>
3
);
// == (y * LCD_WIDTH / 8) + x / 8
...
...
@@ -220,7 +224,7 @@ void lcd_set_pixel(uint16_t x, uint16_t y, uint8_t value)
void
lcd_toggle_pixel
(
uint8_t
x
,
uint8_t
y
)
{
uint8_t
mask
=
1
<<
(
x
&
0x07
);
// == 1 << (x % 8)
uint16_t
offset
=
(
y
*
LCD_WIDTH
>>
3
)
+
x
>>
3
;
// == (y * LCD_WIDTH / 8) + x / 8
uint16_t
offset
=
(
y
*
LCD_WIDTH
>>
3
)
+
(
x
>>
3
);
// == (y * LCD_WIDTH / 8) + x / 8
buffer
[
offset
]
^=
mask
;
}
...
...
@@ -228,7 +232,7 @@ void lcd_toggle_pixel(uint8_t x, uint8_t y)
uint8_t
lcd_get_pixel
(
uint8_t
x
,
uint8_t
y
)
{
uint8_t
mask
=
1
<<
(
x
&
0x07
);
// == 1 << (x % 8)
uint16_t
offset
=
(
y
*
LCD_WIDTH
>>
3
)
+
x
>>
3
;
// == (y * LCD_WIDTH / 8) + x / 8
uint16_t
offset
=
(
y
*
LCD_WIDTH
>>
3
)
+
(
x
>>
3
);
// == (y * LCD_WIDTH / 8) + x / 8
return
buffer
[
offset
]
&
mask
;
}
...
...
sw/common/drivers/lcd.h
View file @
c90aecea
...
...
@@ -20,6 +20,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief LS013B7DH03 LCD driver
*/
#ifndef LCD_H
#define LCD_H
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment