Commit 88d6164e authored by Matthieu Cattin's avatar Matthieu Cattin

Merge branches 'orson_sw_dev' and 'mcattin_sw_dev' into mcattin_sw_dev

parents af6831f6 60d149a2
......@@ -30,8 +30,20 @@
#include <em_rtc.h>
#include <udelay.h>
#define LCD_NODMA
// Additional bytes to control the LCD; required for DMA transfers
#ifdef LCD_NODMA
#define CONTROL_BYTES 0
#else
#define CONTROL_BYTES 2
#endif
// Number of bytes to store one line
#define LCD_STRIDE (LCD_WIDTH / 8 + CONTROL_BYTES)
// Framebuffer - pixels are stored as consecutive rows
static uint8_t buffer[LCD_WIDTH / 8 * LCD_HEIGHT];
static uint8_t buffer[LCD_STRIDE * LCD_HEIGHT];
static void spi_init(void)
{
......@@ -44,7 +56,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, uint16_t length)
{
while(length > 0)
{
......@@ -133,9 +145,8 @@ void lcd_init(void)
rtc_setup(LCD_POL_INV_FREQ);
lcd_power(1);
lcd_enable(1);
lcd_clear();
lcd_enable(1);
}
void lcd_enable(uint8_t enable)
......@@ -156,11 +167,29 @@ void lcd_power(uint8_t enable)
void lcd_clear(void)
{
uint16_t cmd, i;
uint16_t cmd;
uint8_t *p = buffer;
#ifdef LCD_NODMA
uint16_t i;
// Clear pixel buffer
for(i = 0; i < sizeof(buffer); ++i)
buffer[i] = 0x00;
*p++ = 0x00;
#else
uint8_t x, y;
for(y = 0; y < LCD_HEIGHT; ++y)
{
// Clear framebuffer
for(x = 0; x < LCD_WIDTH / 8; ++x)
*p++ = 0x00;
// Add control codes
*p++ = 0xff; // Dummy
*p++ = (y + 2); // Address of next line
}
#endif
// Send command to clear the display
GPIO_PinOutSet(LCD_PORT_SCS, LCD_PIN_SCS);
......@@ -181,7 +210,7 @@ void lcd_update(void)
// TODO use DMA
uint16_t cmd;
uint8_t i;
uint16_t i;
uint8_t *p = (uint8_t*) buffer;
GPIO_PinOutSet(LCD_PORT_SCS, LCD_PIN_SCS);
......@@ -191,6 +220,7 @@ void lcd_update(void)
cmd = LCD_CMD_UPDATE | (START_ROW << 8);
spi_transmit((uint8_t*) &cmd, 2);
#ifdef LCD_NODMA
for(i = 0; i < LCD_HEIGHT; ++i)
{
// Send pixels for this line
......@@ -205,6 +235,14 @@ void lcd_update(void)
spi_transmit((uint8_t*) &cmd, 2);
}
#else
spi_transmit(p, LCD_STRIDE * LCD_HEIGHT);
/*for(i = 0; i < LCD_STRIDE * LCD_HEIGHT / 2; i += 2)
{
spi_transmit(p, 2);
p += 2;
}*/
#endif
timer_delay(2);
GPIO_PinOutClear(LCD_PORT_SCS, LCD_PIN_SCS);
......@@ -212,8 +250,11 @@ void lcd_update(void)
void lcd_set_pixel(uint8_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
x %= LCD_WIDTH;
y %= LCD_HEIGHT;
uint8_t mask = 1 << (x & 0x07); // == 1 << (x % 8)
uint16_t offset = (y * LCD_STRIDE) + (x >> 3); // == y * LCD_STRIDE + x / 8
if(value)
buffer[offset] |= mask;
......@@ -223,16 +264,22 @@ void lcd_set_pixel(uint8_t x, uint8_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
x %= LCD_WIDTH;
y %= LCD_HEIGHT;
uint8_t mask = 1 << (x & 0x07); // == 1 << (x % 8)
uint16_t offset = (y * LCD_STRIDE) + (x >> 3); // == y * LCD_STRIDE + x / 8
buffer[offset] ^= mask;
}
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
x %= LCD_WIDTH;
y %= LCD_HEIGHT;
uint8_t mask = 1 << (x & 0x07); // == 1 << (x % 8)
uint16_t offset = (y * LCD_STRIDE) + (x >> 3); // == y * LCD_STRIDE + x / 8
return buffer[offset] & mask;
}
......
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Basic drawing library.
*/
#ifndef FONT_H
#define FONT_H
#include <stdint.h>
typedef struct
{
uint8_t min_char, max_char, height;
const uint8_t *width_table;
const uint16_t *offset_table;
const uint8_t *glyph_data;
} font;
// List of available fonts
extern const font font_helv11;
extern const font font_helv17;
extern const font font_helv17b;
extern const font font_xm4x5;
extern const font font_xm4x6;
#endif /* FONT_H */
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Font glyphs defintion.
*/
#include "font.h"
static const uint8_t _gw[] = { 2,2,4,5,6,7,6,2,3,3,4,6,2,6,2,3,5,5,5,5,5,5,5,5,5,5,2,2,5,4,5,5,9,6,6,6,6,6,6,6,6,2,4,6,5,7,6,6,6,6,6,6,4,6,6,8,6,6,6,3,2,2,5,5,2,5,5,4,5,4,4,5,5,2,2,4,2,6,5,5,5,5,4,4,4,4,5,6,5,5,4,3,2,3,6};
static const uint16_t _go[] = { 0,11,22,33,44,55,66,77,88,99,110,121,132,143,154,165,176,187,198,209,220,231,242,253,264,275,286,297,308,319,330,341,352,374,385,396,407,418,429,440,451,462,473,484,495,506,517,528,539,550,561,572,583,594,605,616,627,638,649,660,671,682,693,704,715,726,737,748,759,770,781,792,803,814,825,836,847,858,869,880,891,902,913,924,935,946,957,968,979,990,1001,1012,1023,1034,1045};
static const uint8_t _gd[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x00,0x40,0x00,0x00,
0x00,0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00,
0x00,0x00,0x00,0x08,0x1c,0x20,0x18,0x04,0x38,0x10,0x00,
0x00,0x00,0x00,0x74,0x54,0x68,0x16,0x2a,0x2e,0x00,0x00,
0x00,0x00,0x00,0x20,0x50,0x24,0x54,0x58,0x2c,0x00,0x00,
0x00,0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,
0x00,0x00,0x00,0x40,0x20,0x20,0x20,0x20,0x20,0x40,0x00,
0x00,0x00,0x00,0x00,0x20,0x70,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x10,0x7c,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,
0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x40,0x40,0x40,0x00,
0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x48,0x30,0x00,0x00,
0x00,0x00,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x30,0x48,0x08,0x10,0x20,0x78,0x00,0x00,
0x00,0x00,0x00,0x30,0x08,0x30,0x08,0x08,0x30,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x30,0x78,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x38,0x20,0x30,0x08,0x08,0x30,0x00,0x00,
0x00,0x00,0x00,0x38,0x40,0x70,0x48,0x48,0x30,0x00,0x00,
0x00,0x00,0x00,0x78,0x08,0x10,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x30,0x48,0x30,0x48,0x48,0x30,0x00,0x00,
0x00,0x00,0x00,0x30,0x48,0x48,0x38,0x08,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x80,
0x00,0x00,0x00,0x00,0x10,0x20,0x40,0x20,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x20,0x10,0x08,0x10,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x08,0x10,0x00,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x20,0x80,0x4c,0x80,0x52,0x80,0x4f,0x00,0x40,0x00,0x3c,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x28,0x38,0x44,0x44,0x00,0x00,
0x00,0x00,0x00,0x38,0x24,0x38,0x24,0x24,0x38,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00,
0x00,0x00,0x00,0x3c,0x20,0x38,0x20,0x20,0x3c,0x00,0x00,
0x00,0x00,0x00,0x3c,0x20,0x38,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x38,0x40,0x4c,0x44,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x44,0x44,0x7c,0x44,0x44,0x44,0x00,0x00,
0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x50,0x20,0x00,0x00,
0x00,0x00,0x00,0x24,0x28,0x30,0x38,0x24,0x24,0x00,0x00,
0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x38,0x00,0x00,
0x00,0x00,0x00,0x22,0x36,0x2a,0x2a,0x2a,0x2a,0x00,0x00,
0x00,0x00,0x00,0x44,0x64,0x54,0x54,0x4c,0x44,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x38,0x24,0x24,0x38,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x10,0x08,
0x00,0x00,0x00,0x38,0x24,0x24,0x38,0x24,0x24,0x00,0x00,
0x00,0x00,0x00,0x1c,0x20,0x38,0x04,0x04,0x38,0x00,0x00,
0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x24,0x24,0x24,0x24,0x28,0x10,0x00,0x00,
0x00,0x00,0x00,0x49,0x49,0x49,0x36,0x24,0x24,0x00,0x00,
0x00,0x00,0x00,0x24,0x24,0x18,0x18,0x24,0x24,0x00,0x00,
0x00,0x00,0x00,0x64,0x24,0x24,0x18,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x3c,0x04,0x08,0x10,0x20,0x3c,0x00,0x00,
0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x40,0x40,0x60,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0x40,0x40,0x00,
0x00,0x00,0x00,0xc0,0x40,0x40,0x40,0x40,0x40,0xc0,0x00,
0x00,0x00,0x00,0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,
0x00,0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x10,0x70,0x50,0x68,0x00,0x00,
0x00,0x00,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x40,0x40,0x40,0x30,0x00,0x00,
0x00,0x00,0x08,0x08,0x38,0x48,0x48,0x48,0x38,0x00,0x00,
0x00,0x00,0x00,0x00,0x20,0x50,0x70,0x40,0x30,0x00,0x00,
0x00,0x00,0x10,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x38,0x08,0x30,0x00,
0x00,0x00,0x40,0x40,0x70,0x48,0x48,0x48,0x48,0x00,0x00,
0x00,0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
0x00,0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x80,
0x00,0x00,0x40,0x40,0x50,0x60,0x60,0x50,0x50,0x00,0x00,
0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x54,0x54,0x54,0x54,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x48,0x48,0x48,0x48,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x48,0x48,0x48,0x70,0x40,0x00,
0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x00,
0x00,0x00,0x00,0x00,0x50,0x60,0x40,0x40,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x40,0x30,0x10,0x60,0x00,0x00,
0x00,0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x50,0x50,0x50,0x50,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x50,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x54,0x54,0x54,0x28,0x28,0x00,0x00,
0x00,0x00,0x00,0x00,0x48,0x48,0x30,0x48,0x48,0x00,0x00,
0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x30,0x20,0x40,0x00,
0x00,0x00,0x00,0x00,0x70,0x10,0x20,0x40,0x70,0x00,0x00,
0x00,0x00,0x00,0x20,0x40,0x40,0xc0,0x40,0x40,0x20,0x00,
0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
0x00,0x00,0x00,0x80,0x40,0x40,0x60,0x40,0x40,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x24,0x58,0x00,0x00,0x00,0x00
};
const font font_helv11 = {
32, 126, 11,
_gw, _go, _gd
};
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Font glyphs defintion.
*/
#include "font.h"
static const uint8_t _gw[] = { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
static const uint16_t _go[] = { 0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360,365,370,375,380,385,390,395,400,405,410,415,420,425,430,435,440,445,450,455,460,465,470};
static const uint8_t _gd[] = { 0x00,0x00,0x00,0x00,0x00,
0xc0,0xc0,0xc0,0x00,0xc0,
0xa0,0xa0,0x00,0x00,0x00,
0xa0,0xe0,0xa0,0xe0,0xa0,
0x40,0xe0,0xc0,0x60,0xe0,
0xa0,0x60,0xc0,0xa0,0x00,
0x40,0x40,0xe0,0xc0,0x40,
0x20,0x60,0x00,0x00,0x00,
0x20,0x40,0x40,0x40,0x20,
0x80,0x40,0x40,0x40,0x80,
0xa0,0x40,0xe0,0x40,0xa0,
0x00,0x40,0xe0,0x40,0x00,
0x00,0x00,0x00,0x40,0xc0,
0x00,0x00,0xe0,0x00,0x00,
0x00,0x00,0x00,0xc0,0xc0,
0x20,0x20,0x40,0x40,0x80,
0x40,0xa0,0xa0,0xa0,0x40,
0x40,0xc0,0x40,0x40,0x40,
0xc0,0x20,0x40,0x80,0xe0,
0xc0,0x20,0x60,0x20,0xe0,
0xa0,0xa0,0xa0,0xe0,0x20,
0xe0,0x80,0xc0,0x20,0xc0,
0x60,0x80,0xe0,0xa0,0xe0,
0xe0,0x20,0x20,0x40,0x40,
0xe0,0xa0,0xe0,0xa0,0xe0,
0xe0,0xa0,0xe0,0x20,0xc0,
0xc0,0xc0,0x00,0xc0,0xc0,
0xc0,0xc0,0x00,0x40,0xc0,
0x20,0x40,0x80,0x40,0x20,
0x00,0xe0,0x00,0xe0,0x00,
0x80,0x40,0x20,0x40,0x80,
0xe0,0x20,0x60,0x00,0x40,
0x60,0xa0,0xc0,0x80,0x60,
0xe0,0xa0,0xe0,0xa0,0xa0,
0xe0,0xa0,0xc0,0xa0,0xe0,
0xe0,0x80,0x80,0x80,0xe0,
0xc0,0xa0,0xa0,0xa0,0xc0,
0xe0,0x80,0xe0,0x80,0xe0,
0xe0,0x80,0xe0,0x80,0x80,
0xe0,0x80,0xa0,0xa0,0xe0,
0xa0,0xa0,0xe0,0xa0,0xa0,
0xe0,0x40,0x40,0x40,0xe0,
0x20,0x20,0x20,0xa0,0xe0,
0xa0,0xa0,0xc0,0xa0,0xa0,
0x80,0x80,0x80,0x80,0xe0,
0xa0,0xe0,0xa0,0xa0,0xa0,
0xe0,0xa0,0xa0,0xa0,0xa0,
0xe0,0xa0,0xa0,0xa0,0xe0,
0xe0,0xa0,0xe0,0x80,0x80,
0xe0,0xa0,0xa0,0xc0,0x60,
0xe0,0xa0,0xc0,0xa0,0xa0,
0xe0,0x80,0xe0,0x20,0xe0,
0xe0,0x40,0x40,0x40,0x40,
0xa0,0xa0,0xa0,0xa0,0xe0,
0xa0,0xa0,0xa0,0xa0,0x40,
0xa0,0xa0,0xa0,0xe0,0xa0,
0xa0,0xe0,0x40,0xe0,0xa0,
0xa0,0xa0,0xe0,0x40,0x40,
0xe0,0x20,0x40,0x80,0xe0,
0x60,0x40,0x40,0x40,0x60,
0x80,0x80,0x40,0x40,0x20,
0xc0,0x40,0x40,0x40,0xc0,
0x40,0xa0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xe0,
0x40,0x60,0x00,0x00,0x00,
0x00,0xe0,0x60,0xa0,0xe0,
0x80,0xe0,0xa0,0xa0,0xe0,
0x00,0xe0,0x80,0x80,0xe0,
0x20,0xe0,0xa0,0xa0,0xe0,
0x00,0xe0,0xa0,0xc0,0xe0,
0x60,0x80,0xc0,0x80,0x80,
0x00,0xe0,0xa0,0x60,0xe0,
0x80,0xe0,0xa0,0xa0,0xa0,
0x00,0x40,0x40,0x40,0x40,
0x00,0x20,0x20,0xa0,0xe0,
0x80,0xa0,0xc0,0xc0,0xa0,
0xc0,0x40,0x40,0x40,0x40,
0x00,0xa0,0xe0,0xa0,0xa0,
0x00,0xe0,0xa0,0xa0,0xa0,
0x00,0xe0,0xa0,0xa0,0xe0,
0x00,0xe0,0xa0,0xe0,0x80,
0x00,0xe0,0xa0,0xe0,0x20,
0x00,0xe0,0xa0,0x80,0x80,
0x00,0xe0,0xc0,0x60,0xe0,
0x40,0xe0,0x40,0x40,0x60,
0x00,0xa0,0xa0,0xa0,0xe0,
0x00,0xa0,0xa0,0xa0,0x40,
0x00,0xa0,0xa0,0xe0,0xa0,
0x00,0xa0,0x40,0x40,0xa0,
0x00,0xa0,0xa0,0x60,0xc0,
0x00,0xe0,0x60,0xc0,0xe0,
0x60,0x40,0xc0,0x40,0x60,
0x40,0x40,0x40,0x40,0x40,
0xc0,0x40,0x60,0x40,0xc0,
0x00,0xc0,0x60,0x00,0x00
};
const font font_xm4x5 = {
32, 126, 5,
_gw, _go, _gd
};
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Font glyphs defintion.
*/
#include "font.h"
static const uint8_t _gw[] = { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
static const uint16_t _go[] = { 0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102,108,114,120,126,132,138,144,150,156,162,168,174,180,186,192,198,204,210,216,222,228,234,240,246,252,258,264,270,276,282,288,294,300,306,312,318,324,330,336,342,348,354,360,366,372,378,384,390,396,402,408,414,420,426,432,438,444,450,456,462,468,474,480,486,492,498,504,510,516,522,528,534,540,546,552,558,564};
static const uint8_t _gd[] = { 0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x40,0x00,0x40,0x00,
0xa0,0xa0,0x00,0x00,0x00,0x00,
0xa0,0xe0,0xa0,0xe0,0xa0,0x00,
0xe0,0xc0,0xe0,0x60,0xe0,0x00,
0xa0,0x20,0x40,0x80,0xa0,0x00,
0xe0,0x40,0xe0,0xa0,0xe0,0x00,
0x20,0x40,0x00,0x00,0x00,0x00,
0x20,0x40,0x40,0x40,0x20,0x00,
0x40,0x20,0x20,0x20,0x40,0x00,
0x40,0x40,0xe0,0x40,0xa0,0x00,
0x00,0x40,0xe0,0x40,0x00,0x00,
0x00,0x00,0x00,0x20,0x40,0x00,
0x00,0x00,0xe0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,
0x20,0x20,0x40,0x80,0x80,0x00,
0xe0,0xa0,0xa0,0xa0,0xe0,0x00,
0x40,0xc0,0x40,0x40,0x40,0x00,
0xe0,0x20,0xe0,0x80,0xe0,0x00,
0xe0,0x20,0xe0,0x20,0xe0,0x00,
0xa0,0xa0,0xe0,0x20,0x20,0x00,
0xe0,0x80,0xe0,0x20,0xe0,0x00,
0xe0,0x80,0xe0,0xa0,0xe0,0x00,
0xe0,0x20,0x20,0x20,0x20,0x00,
0xe0,0xa0,0xe0,0xa0,0xe0,0x00,
0xe0,0xa0,0xe0,0x20,0xe0,0x00,
0x00,0x40,0x00,0x40,0x00,0x00,
0x00,0x20,0x00,0x20,0x40,0x00,
0x20,0x40,0x80,0x40,0x20,0x00,
0x00,0xe0,0x00,0xe0,0x00,0x00,
0x80,0x40,0x20,0x40,0x80,0x00,
0xc0,0x20,0x40,0x00,0x40,0x00,
0xe0,0xa0,0xe0,0x80,0xe0,0x00,
0x40,0xa0,0xe0,0xa0,0xa0,0x00,
0xc0,0xa0,0xc0,0xa0,0xc0,0x00,
0x60,0x80,0x80,0x80,0x60,0x00,
0xc0,0xa0,0xa0,0xa0,0xc0,0x00,
0xe0,0x80,0xc0,0x80,0xe0,0x00,
0xe0,0x80,0xc0,0x80,0x80,0x00,
0x60,0x80,0xa0,0xa0,0x60,0x00,
0xa0,0xa0,0xe0,0xa0,0xa0,0x00,
0xe0,0x40,0x40,0x40,0xe0,0x00,
0x20,0x20,0x20,0xa0,0x40,0x00,
0xa0,0xa0,0xc0,0xa0,0xa0,0x00,
0x80,0x80,0x80,0x80,0xe0,0x00,
0xa0,0xe0,0xe0,0xa0,0xa0,0x00,
0xa0,0xe0,0xe0,0xe0,0xa0,0x00,
0x40,0xa0,0xa0,0xa0,0x40,0x00,
0xc0,0xa0,0xc0,0x80,0x80,0x00,
0x40,0xa0,0xa0,0xc0,0x60,0x00,
0xc0,0xa0,0xc0,0xa0,0xa0,0x00,
0x60,0x80,0x40,0x20,0xc0,0x00,
0xe0,0x40,0x40,0x40,0x40,0x00,
0xa0,0xa0,0xa0,0xa0,0xe0,0x00,
0xa0,0xa0,0xa0,0xa0,0x40,0x00,
0xa0,0xa0,0xe0,0xe0,0xa0,0x00,
0xa0,0xa0,0x40,0xa0,0xa0,0x00,
0xa0,0xa0,0x40,0x40,0x40,0x00,
0xe0,0x20,0x40,0x80,0xe0,0x00,
0x60,0x40,0x40,0x40,0x60,0x00,
0x80,0x80,0x40,0x20,0x20,0x00,
0x60,0x20,0x20,0x20,0x60,0x00,
0x40,0xa0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xe0,0x00,
0x40,0x20,0x00,0x00,0x00,0x00,
0x00,0x40,0xa0,0xa0,0x60,0x00,
0x80,0xc0,0xa0,0xa0,0xc0,0x00,
0x00,0x60,0x80,0x80,0x60,0x00,
0x20,0x60,0xa0,0xa0,0x60,0x00,
0x00,0x60,0xe0,0x80,0x60,0x00,
0x20,0x40,0xe0,0x40,0x40,0x00,
0x00,0x60,0xa0,0x60,0x20,0xc0,
0x80,0xc0,0xa0,0xa0,0xa0,0x00,
0x40,0x00,0x40,0x40,0x40,0x00,
0x20,0x00,0x20,0x20,0xa0,0x40,
0x80,0xa0,0xc0,0xc0,0xa0,0x00,
0x40,0x40,0x40,0x40,0x40,0x00,
0x00,0xe0,0xe0,0xe0,0xa0,0x00,
0x00,0xc0,0xa0,0xa0,0xa0,0x00,
0x00,0x40,0xa0,0xa0,0x40,0x00,
0x00,0xc0,0xa0,0xc0,0x80,0x80,
0x00,0x60,0xa0,0x60,0x20,0x20,
0x00,0xc0,0xa0,0x80,0x80,0x00,
0x00,0x60,0xc0,0x60,0xc0,0x00,
0x40,0xe0,0x40,0x40,0x40,0x00,
0x00,0xa0,0xa0,0xa0,0xe0,0x00,
0x00,0xa0,0xa0,0xa0,0x40,0x00,
0x00,0xa0,0xe0,0xe0,0xe0,0x00,
0x00,0xa0,0x40,0x40,0xa0,0x00,
0x00,0xa0,0xa0,0x60,0x20,0xc0,
0x00,0xe0,0x60,0xc0,0xe0,0x00,
0x60,0x40,0xc0,0x40,0x60,0x00,
0x40,0x40,0x00,0x40,0x40,0x00,
0xc0,0x40,0x60,0x40,0xc0,0x00,
0x20,0xe0,0x80,0x00,0x00,0x00
};
const font font_xm4x6 = {
32, 126, 6,
_gw, _go, _gd
};
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Basic drawing library.
*/
#include "graphics.h"
#include <drivers/lcd.h>
#include <stdlib.h>
void line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t value)
{
int8_t dx = abs(x1 - x0);
int8_t sx = x0 < x1 ? 1 : -1;
int8_t dy = abs(y1 - y0);
int8_t sy = y0 < y1 ? 1 : -1;
int8_t err = (dx > dy ? dx : -dy) / 2;
int8_t e2;
for(;;)
{
lcd_set_pixel(x0, y0, value);
if(x0 == x1 && y0 == y1)
break;
e2 = err;
if(e2 > -dx) { err -= dy; x0 += sx; }
if(e2 < dy) { err += dx; y0 += sy; }
}
}
void box(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t value)
{
uint8_t x, y;
for(x = x0; x <= x1; x++)
{
for(y = y0; y <= y1; y++)
{
lcd_set_pixel(x, y, value);
}
}
}
uint8_t draw_glyph(const font *font, uint8_t x0, uint8_t y0, char c)
{
if(c < font->min_char || c > font->max_char)
return 0;
const uint8_t *buf = font->glyph_data + font->offset_table[c - font->min_char];
uint8_t w = font->width_table[c - font->min_char];
uint8_t x, y;
for(y = 0; y < font->height; y++)
{
for(x = 0; x < w; x++)
{
if(buf[((w + 7) >> 3) * y + (x >> 3)] & (1 << (7 - (x & 7))))
lcd_set_pixel(x + x0, y + y0, c);
}
}
return w;
}
void text(const font *font, uint8_t x, uint8_t y, const char *str)
{
char c;
while((c = *str++))
x += draw_glyph(font, x, y, c);
}
/*
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Basic drawing library.
*/
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "font.h"
/*
* @brief TODO
*/
void line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t value);
/**
* @brief TODO
*/
void box(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t value);
/**
* @brief TODO
*/
uint8_t draw_glyph(const font *font, uint8_t x0, uint8_t y0, char c);
/**
* @brief TODO
*/
void text(const font *font, uint8_t x, uint8_t y, const char *str);
#endif /* GRAPHICS_H */
......@@ -143,8 +143,6 @@ INCLUDEPATHS += \
C_SRC += \
../common/Device/EnergyMicro/EFM32GG/Source/system_efm32gg.c \
../common/drivers/lcd.c \
../common/drivers/i2cdrv.c \
../common/drivers/max17047_battery.c \
../common/emlib/src/em_assert.c \
../common/emlib/src/em_cmu.c \
../common/emlib/src/em_emu.c \
......@@ -154,6 +152,12 @@ C_SRC += \
../common/emlib/src/em_system.c \
../common/emlib/src/em_rtc.c \
../common/emlib/src/em_usart.c \
../common/gfx/graphics.c \
../common/gfx/font_helv11.c \
../common/gfx/font_helv17.c \
../common/gfx/font_helv17b.c \
../common/gfx/font_xm4x5.c \
../common/gfx/font_xm4x6.c \
../common/udelay.c \
main.c
#../common/drivers/display.c \
......
......@@ -24,10 +24,11 @@
* @brief Main file.
*/
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "lcd.h"
#include <em_device.h>
#include <em_cmu.h>
#include <em_gpio.h>
#include <drivers/lcd.h>
#include <gfx/graphics.h>
/* Counts 1ms timeTicks */
volatile uint32_t msTicks;
......@@ -71,9 +72,24 @@ int main(void)
GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
lcd_init();
for(x = 0; x < LCD_WIDTH; ++x)
for(y = 0; y < LCD_HEIGHT; ++y)
for(x = 0; x < LCD_WIDTH / 2; ++x)
{
for(y = 0; y < LCD_HEIGHT / 2; ++y)
{
lcd_set_pixel(x, y, (x >> 4 ^ y >> 4) % 2);
}
}
text(&font_helv11, 5, 65, "helv11");
text(&font_helv17, 5, 75, "helv17");
text(&font_helv17b, 5, 90, "helv17b");
text(&font_xm4x5, 5, 110, "xm4x5");
text(&font_xm4x6, 5, 120, "xm4x6");
box(100, 100, 120, 120, 1);
line(100, 40, 120, 70, 1);
lcd_update();
/* Infinite blink loop */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment