/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/.directory |
---|
0,0 → 1,3 |
[Dolphin] |
Timestamp=2013,3,7,9,13,59 |
ViewMode=1 |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/Font8x8.c |
---|
0,0 → 1,273 |
/* |
* font8x8.c |
* LCD-OSD |
* |
* Created by Peter Mack on 26.12.09. |
* Copyright 2009 SCS GmbH & Co. KG. All rights reserved. |
* |
*/ |
#include <avr/pgmspace.h> |
const uint8_t Font8x8[256][8]PROGMEM= |
{ |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 |
{0x7E,0x81,0x95,0xB1,0xB1,0x95,0x81,0x7E}, // 0x01 |
{0x7E,0xFF,0xEB,0xCF,0xCF,0xEB,0xFF,0x7E}, // 0x02 |
{0x0E,0x1F,0x3F,0x7E,0x3F,0x1F,0x0E,0x00}, // 0x03 |
{0x08,0x1C,0x3E,0x7F,0x3E,0x1C,0x08,0x00}, // 0x04 |
{0x38,0x3A,0x9F,0xFF,0x9F,0x3A,0x38,0x00}, // 0x05 |
{0x10,0x38,0xBC,0xFF,0xBC,0x38,0x10,0x00}, // 0x06 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A |
{0x70,0xF8,0x88,0x88,0xFD,0x7F,0x07,0x0F}, // 0x0B |
{0x00,0x4E,0x5F,0xF1,0xF1,0x5F,0x4E,0x00}, // 0x0C |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D |
{0xC0,0xFF,0x7F,0x05,0x05,0x65,0x7F,0x3F}, // 0x0E |
{0x99,0x5A,0x3C,0xE7,0xE7,0x3C,0x5A,0x99}, // 0x0F |
{0x7F,0x3E,0x3E,0x1C,0x1C,0x08,0x08,0x00}, // 0x10 |
{0x08,0x08,0x1C,0x1C,0x3E,0x3E,0x7F,0x00}, // 0x11 |
{0x00,0x24,0x66,0xFF,0xFF,0x66,0x24,0x00}, // 0x12 |
{0x00,0x5F,0x5F,0x00,0x00,0x5F,0x5F,0x00}, // 0x13 |
{0x06,0x0F,0x09,0x7F,0x7F,0x01,0x7F,0x7F}, // 0x14 |
{0xDA,0xBF,0xA5,0xA5,0xFD,0x59,0x03,0x02}, // 0x15 |
{0x00,0x70,0x70,0x70,0x70,0x70,0x70,0x00}, // 0x16 |
{0x80,0x94,0xB6,0xFF,0xFF,0xB6,0x94,0x80}, // 0x17 |
{0x00,0x04,0x06,0x7F,0x7F,0x06,0x04,0x00}, // 0x18 |
{0x00,0x10,0x30,0x7F,0x7F,0x30,0x10,0x00}, // 0x19 |
{0x08,0x08,0x08,0x2A,0x3E,0x1C,0x08,0x00}, // 0x1A |
{0x08,0x1C,0x3E,0x2A,0x08,0x08,0x08,0x00}, // 0x1B |
{0x3C,0x3C,0x20,0x20,0x20,0x20,0x20,0x00}, // 0x1C |
{0x08,0x1C,0x3E,0x08,0x08,0x3E,0x1C,0x08}, // 0x1D |
{0x30,0x38,0x3C,0x3E,0x3E,0x3C,0x38,0x30}, // 0x1E |
{0x06,0x0E,0x1E,0x3E,0x3E,0x1E,0x0E,0x06}, // 0x1F |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20 |
{0x00,0x06,0x5F,0x5F,0x06,0x00,0x00,0x00}, // 0x21 |
{0x00,0x07,0x07,0x00,0x07,0x07,0x00,0x00}, // 0x22 |
{0x14,0x7F,0x7F,0x14,0x7F,0x7F,0x14,0x00}, // 0x23 |
{0x24,0x2E,0x6B,0x6B,0x3A,0x12,0x00,0x00}, // 0x24 |
{0x46,0x66,0x30,0x18,0x0C,0x66,0x62,0x00}, // 0x25 |
{0x30,0x7A,0x4F,0x5D,0x37,0x7A,0x48,0x00}, // 0x26 |
{0x04,0x07,0x03,0x00,0x00,0x00,0x00,0x00}, // 0x27 |
{0x00,0x1C,0x3E,0x63,0x41,0x00,0x00,0x00}, // 0x28 |
{0x00,0x41,0x63,0x3E,0x1C,0x00,0x00,0x00}, // 0x29 |
{0x08,0x2A,0x3E,0x1C,0x1C,0x3E,0x2A,0x08}, // 0x2A |
{0x08,0x08,0x3E,0x3E,0x08,0x08,0x00,0x00}, // 0x2B |
{0x00,0xA0,0xE0,0x60,0x00,0x00,0x00,0x00}, // 0x2C |
{0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00}, // 0x2D |
{0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00}, // 0x2E |
{0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00}, // 0x2F |
{0x3E,0x7F,0x59,0x4D,0x7F,0x3E,0x00,0x00}, // 0x30 |
{0x42,0x42,0x7F,0x7F,0x40,0x40,0x00,0x00}, // 0x31 |
{0x62,0x73,0x59,0x49,0x6F,0x66,0x00,0x00}, // 0x32 |
{0x22,0x63,0x49,0x49,0x7F,0x36,0x00,0x00}, // 0x33 |
{0x18,0x1C,0x16,0x13,0x7F,0x7F,0x10,0x00}, // 0x34 |
{0x27,0x67,0x45,0x45,0x7D,0x39,0x00,0x00}, // 0x35 |
{0x3C,0x7E,0x4B,0x49,0x79,0x30,0x00,0x00}, // 0x36 |
{0x03,0x63,0x71,0x19,0x0F,0x07,0x00,0x00}, // 0x37 |
{0x36,0x7F,0x49,0x49,0x7F,0x36,0x00,0x00}, // 0x38 |
{0x06,0x4F,0x49,0x69,0x3F,0x1E,0x00,0x00}, // 0x39 |
{0x00,0x00,0x6C,0x6C,0x00,0x00,0x00,0x00}, // 0x3A |
{0x00,0xA0,0xEC,0x6C,0x00,0x00,0x00,0x00}, // 0x3B |
{0x08,0x1C,0x36,0x63,0x41,0x00,0x00,0x00}, // 0x3C |
{0x14,0x14,0x14,0x14,0x14,0x14,0x00,0x00}, // 0x3D |
{0x00,0x41,0x63,0x36,0x1C,0x08,0x00,0x00}, // 0x3E |
{0x02,0x03,0x51,0x59,0x0F,0x06,0x00,0x00}, // 0x3F |
{0x3E,0x7F,0x41,0x5D,0x5D,0x1F,0x1E,0x00}, // 0x40 |
{0x7C,0x7E,0x13,0x13,0x7E,0x7C,0x00,0x00}, // 0x41 |
{0x41,0x7F,0x7F,0x49,0x49,0x7F,0x36,0x00}, // 0x42 |
{0x1C,0x3E,0x63,0x41,0x41,0x63,0x22,0x00}, // 0x43 |
{0x41,0x7F,0x7F,0x41,0x63,0x7F,0x1C,0x00}, // 0x44 |
{0x41,0x7F,0x7F,0x49,0x5D,0x41,0x63,0x00}, // 0x45 |
{0x41,0x7F,0x7F,0x49,0x1D,0x01,0x03,0x00}, // 0x46 |
{0x1C,0x3E,0x63,0x41,0x51,0x73,0x72,0x00}, // 0x47 |
{0x7F,0x7F,0x08,0x08,0x7F,0x7F,0x00,0x00}, // 0x48 |
{0x00,0x41,0x7F,0x7F,0x41,0x00,0x00,0x00}, // 0x49 |
{0x30,0x70,0x40,0x41,0x7F,0x3F,0x01,0x00}, // 0x4A |
{0x41,0x7F,0x7F,0x08,0x1C,0x77,0x63,0x00}, // 0x4B |
{0x41,0x7F,0x7F,0x41,0x40,0x60,0x70,0x00}, // 0x4C |
{0x7F,0x7F,0x06,0x0C,0x06,0x7F,0x7F,0x00}, // 0x4D |
{0x7F,0x7F,0x06,0x0C,0x18,0x7F,0x7F,0x00}, // 0x4E |
{0x1C,0x3E,0x63,0x41,0x63,0x3E,0x1C,0x00}, // 0x4F |
{0x41,0x7F,0x7F,0x49,0x09,0x0F,0x06,0x00}, // 0x50 |
{0x1E,0x3F,0x21,0x71,0x7F,0x5E,0x00,0x00}, // 0x51 |
{0x41,0x7F,0x7F,0x19,0x39,0x6F,0x46,0x00}, // 0x52 |
{0x26,0x67,0x4D,0x59,0x7B,0x32,0x00,0x00}, // 0x53 |
{0x03,0x41,0x7F,0x7F,0x41,0x03,0x00,0x00}, // 0x54 |
{0x7F,0x7F,0x40,0x40,0x7F,0x7F,0x00,0x00}, // 0x55 |
{0x1F,0x3F,0x60,0x60,0x3F,0x1F,0x00,0x00}, // 0x56 |
{0x7F,0x7F,0x30,0x18,0x30,0x7F,0x7F,0x00}, // 0x57 |
{0x63,0x77,0x1C,0x08,0x1C,0x77,0x63,0x00}, // 0x58 |
{0x07,0x4F,0x78,0x78,0x4F,0x07,0x00,0x00}, // 0x59 |
{0x67,0x73,0x59,0x4D,0x47,0x63,0x71,0x00}, // 0x5A |
{0x00,0x7F,0x7F,0x41,0x41,0x00,0x00,0x00}, // 0x5B |
{0x01,0x03,0x06,0x0C,0x18,0x30,0x60,0x00}, // 0x5C |
{0x00,0x41,0x41,0x7F,0x7F,0x00,0x00,0x00}, // 0x5D |
{0x08,0x0C,0x06,0x03,0x06,0x0C,0x08,0x00}, // 0x5E |
{0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, // 0x5F |
{0x00,0x00,0x03,0x07,0x04,0x00,0x00,0x00}, // 0x60 |
{0x20,0x74,0x54,0x54,0x3C,0x78,0x40,0x00}, // 0x61 |
{0x41,0x3F,0x7F,0x44,0x44,0x7C,0x38,0x00}, // 0x62 |
{0x38,0x7C,0x44,0x44,0x6C,0x28,0x00,0x00}, // 0x63 |
{0x30,0x78,0x48,0x49,0x3F,0x7F,0x40,0x00}, // 0x64 |
{0x38,0x7C,0x54,0x54,0x5C,0x18,0x00,0x00}, // 0x65 |
{0x48,0x7E,0x7F,0x49,0x03,0x02,0x00,0x00}, // 0x66 |
{0x98,0xBC,0xA4,0xA4,0xF8,0x7C,0x04,0x00}, // 0x67 |
{0x41,0x7F,0x7F,0x08,0x04,0x7C,0x78,0x00}, // 0x68 |
{0x00,0x44,0x7D,0x7D,0x40,0x00,0x00,0x00}, // 0x69 |
{0x40,0xC4,0x84,0xFD,0x7D,0x00,0x00,0x00}, // 0x6A |
{0x41,0x7F,0x7F,0x10,0x38,0x6C,0x44,0x00}, // 0x6B |
{0x00,0x41,0x7F,0x7F,0x40,0x00,0x00,0x00}, // 0x6C |
{0x7C,0x7C,0x0C,0x18,0x0C,0x7C,0x78,0x00}, // 0x6D |
{0x7C,0x7C,0x04,0x04,0x7C,0x78,0x00,0x00}, // 0x6E |
{0x38,0x7C,0x44,0x44,0x7C,0x38,0x00,0x00}, // 0x6F |
{0x84,0xFC,0xF8,0xA4,0x24,0x3C,0x18,0x00}, // 0x70 |
{0x18,0x3C,0x24,0xA4,0xF8,0xFC,0x84,0x00}, // 0x71 |
{0x44,0x7C,0x78,0x44,0x1C,0x18,0x00,0x00}, // 0x72 |
{0x48,0x5C,0x54,0x54,0x74,0x24,0x00,0x00}, // 0x73 |
{0x00,0x04,0x3E,0x7F,0x44,0x24,0x00,0x00}, // 0x74 |
{0x3C,0x7C,0x40,0x40,0x3C,0x7C,0x40,0x00}, // 0x75 |
{0x1C,0x3C,0x60,0x60,0x3C,0x1C,0x00,0x00}, // 0x76 |
{0x3C,0x7C,0x60,0x30,0x60,0x7C,0x3C,0x00}, // 0x77 |
{0x44,0x6C,0x38,0x10,0x38,0x6C,0x44,0x00}, // 0x78 |
{0x9C,0xBC,0xA0,0xA0,0xFC,0x7C,0x00,0x00}, // 0x79 |
{0x4C,0x64,0x74,0x5C,0x4C,0x64,0x00,0x00}, // 0x7A |
{0x08,0x08,0x3E,0x77,0x41,0x41,0x00,0x00}, // 0x7B |
{0x00,0x00,0x00,0x77,0x77,0x00,0x00,0x00}, // 0x7C |
{0x41,0x41,0x77,0x3E,0x08,0x08,0x00,0x00}, // 0x7D |
{0x02,0x03,0x01,0x03,0x02,0x03,0x01,0x00}, // 0x7E |
{0x78,0x7C,0x46,0x43,0x46,0x7C,0x78,0x00}, // 0x7F |
{0x1E,0xBF,0xE1,0x61,0x33,0x12,0x00,0x00}, // 0x80 |
{0x3A,0x7A,0x40,0x40,0x7A,0x7A,0x40,0x00}, // 0x81 |
{0x38,0x7C,0x56,0x57,0x5D,0x18,0x00,0x00}, // 0x82 |
{0x02,0x23,0x75,0x55,0x55,0x7D,0x7B,0x42}, // 0x83 |
{0x21,0x75,0x54,0x54,0x7D,0x79,0x40,0x00}, // 0x84 |
{0x20,0x75,0x57,0x56,0x7C,0x78,0x40,0x00}, // 0x85 |
{0x00,0x22,0x77,0x55,0x55,0x7F,0x7A,0x40}, // 0x86 |
{0x1C,0xBE,0xE2,0x62,0x36,0x14,0x00,0x00}, // 0x87 |
{0x02,0x3B,0x7D,0x55,0x55,0x5D,0x1B,0x02}, // 0x88 |
{0x39,0x7D,0x54,0x54,0x5D,0x19,0x00,0x00}, // 0x89 |
{0x38,0x7D,0x57,0x56,0x5C,0x18,0x00,0x00}, // 0x8A |
{0x01,0x45,0x7C,0x7C,0x41,0x01,0x00,0x00}, // 0x8B |
{0x02,0x03,0x45,0x7D,0x7D,0x43,0x02,0x00}, // 0x8C |
{0x00,0x45,0x7F,0x7E,0x40,0x00,0x00,0x00}, // 0x8D |
{0x79,0x7D,0x26,0x26,0x7D,0x79,0x00,0x00}, // 0x8E |
{0x70,0x7A,0x2D,0x2D,0x7A,0x70,0x00,0x00}, // 0x8F |
{0x44,0x7C,0x7E,0x57,0x55,0x44,0x00,0x00}, // 0x90 |
{0x20,0x74,0x54,0x54,0x7C,0x7C,0x54,0x54}, // 0x91 |
{0x7C,0x7E,0x0B,0x09,0x7F,0x7F,0x49,0x00}, // 0x92 |
{0x32,0x7B,0x49,0x49,0x7B,0x32,0x00,0x00}, // 0x93 |
{0x32,0x7A,0x48,0x48,0x7A,0x32,0x00,0x00}, // 0x94 |
{0x30,0x79,0x4B,0x4A,0x78,0x30,0x00,0x00}, // 0x95 |
{0x3A,0x7B,0x41,0x41,0x7B,0x7A,0x40,0x00}, // 0x96 |
{0x38,0x79,0x43,0x42,0x78,0x78,0x40,0x00}, // 0x97 |
{0xBA,0xBA,0xA0,0xA0,0xFA,0x7A,0x00,0x00}, // 0x98 |
{0x39,0x7D,0x44,0x44,0x44,0x7D,0x39,0x00}, // 0x99 |
{0x3D,0x7D,0x40,0x40,0x7D,0x3D,0x00,0x00}, // 0x9A |
{0x38,0x7C,0x64,0x54,0x4C,0x7C,0x38,0x00}, // 0x9B |
{0x68,0x7E,0x7F,0x49,0x43,0x66,0x20,0x00}, // 0x9C |
{0x5C,0x3E,0x73,0x49,0x67,0x3E,0x1D,0x00}, // 0x9D |
{0x44,0x6C,0x38,0x38,0x6C,0x44,0x00,0x00}, // 0x9E |
{0x40,0xC8,0x88,0xFE,0x7F,0x09,0x0B,0x02}, // 0x9F |
{0x20,0x74,0x56,0x57,0x7D,0x78,0x40,0x00}, // 0xA0 |
{0x00,0x44,0x7E,0x7F,0x41,0x00,0x00,0x00}, // 0xA1 |
{0x30,0x78,0x48,0x4A,0x7B,0x31,0x00,0x00}, // 0xA2 |
{0x38,0x78,0x40,0x42,0x7B,0x79,0x40,0x00}, // 0xA3 |
{0x7A,0x7B,0x09,0x0B,0x7A,0x73,0x01,0x00}, // 0xA4 |
{0x7A,0x7B,0x19,0x33,0x7A,0x7B,0x01,0x00}, // 0xA5 |
{0x00,0x26,0x2F,0x29,0x2F,0x2F,0x28,0x00}, // 0xA6 |
{0x00,0x26,0x2F,0x29,0x29,0x2F,0x26,0x00}, // 0xA7 |
{0x30,0x78,0x4D,0x45,0x60,0x20,0x00,0x00}, // 0xA8 |
{0x1C,0x22,0x7D,0x4B,0x5B,0x65,0x22,0x1C}, // 0xA9 |
{0x08,0x08,0x08,0x08,0x38,0x38,0x00,0x00}, // 0xAA |
{0x61,0x3F,0x1F,0xCC,0xEE,0xAB,0xB9,0x90}, // 0xAB |
{0x61,0x3F,0x1F,0x4C,0x66,0x73,0xD9,0xF8}, // 0xAC |
{0x00,0x00,0x60,0xFA,0xFA,0x60,0x00,0x00}, // 0xAD |
{0x08,0x1C,0x36,0x22,0x08,0x1C,0x36,0x22}, // 0xAE |
{0x22,0x36,0x1C,0x08,0x22,0x36,0x1C,0x08}, // 0xAF |
{0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00}, // 0xB0 |
{0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55}, // 0xB1 |
{0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF}, // 0xB2 |
{0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00}, // 0xB3 |
{0x10,0x10,0x10,0xFF,0xFF,0x00,0x00,0x00}, // 0xB4 |
{0x70,0x78,0x2C,0x2E,0x7B,0x71,0x00,0x00}, // 0xB5 |
{0x72,0x79,0x2D,0x2D,0x79,0x72,0x00,0x00}, // 0xB6 |
{0x71,0x7B,0x2E,0x2C,0x78,0x70,0x00,0x00}, // 0xB7 |
{0x1C,0x22,0x5D,0x55,0x55,0x41,0x22,0x1C}, // 0xB8 |
{0x14,0x14,0xF7,0xF7,0x00,0xFF,0xFF,0x00}, // 0xB9 |
{0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00}, // 0xBA |
{0x14,0x14,0xF4,0xF4,0x04,0xFC,0xFC,0x00}, // 0xBB |
{0x14,0x14,0x17,0x17,0x10,0x1F,0x1F,0x00}, // 0xBC |
{0x18,0x3C,0x24,0xE7,0xE7,0x24,0x24,0x00}, // 0xBD |
{0x2B,0x2F,0xFC,0xFC,0x2F,0x2B,0x00,0x00}, // 0xBE |
{0x10,0x10,0x10,0xF0,0xF0,0x00,0x00,0x00}, // 0xBF |
{0x00,0x00,0x00,0x1F,0x1F,0x10,0x10,0x10}, // 0xC0 |
{0x10,0x10,0x10,0x1F,0x1F,0x10,0x10,0x10}, // 0xC1 |
{0x10,0x10,0x10,0xF0,0xF0,0x10,0x10,0x10}, // 0xC2 |
{0x00,0x00,0x00,0xFF,0xFF,0x10,0x10,0x10}, // 0xC3 |
{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10}, // 0xC4 |
{0x10,0x10,0x10,0xFF,0xFF,0x10,0x10,0x10}, // 0xC5 |
{0x22,0x77,0x55,0x57,0x7E,0x7B,0x41,0x00}, // 0xC6 |
{0x72,0x7B,0x2D,0x2F,0x7A,0x73,0x01,0x00}, // 0xC7 |
{0x00,0x00,0x1F,0x1F,0x10,0x17,0x17,0x14}, // 0xC8 |
{0x00,0x00,0xFC,0xFC,0x04,0xF4,0xF4,0x14}, // 0xC9 |
{0x14,0x14,0x17,0x17,0x10,0x17,0x17,0x14}, // 0xCA |
{0x14,0x14,0xF4,0xF4,0x04,0xF4,0xF4,0x14}, // 0xCB |
{0x00,0x00,0xFF,0xFF,0x00,0xF7,0xF7,0x14}, // 0xCC |
{0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14}, // 0xCD |
{0x14,0x14,0xF7,0xF7,0x00,0xF7,0xF7,0x14}, // 0xCE |
{0x66,0x3C,0x3C,0x24,0x3C,0x3C,0x66,0x00}, // 0xCF |
{0x05,0x27,0x72,0x57,0x7D,0x38,0x00,0x00}, // 0xD0 |
{0x49,0x7F,0x7F,0x49,0x63,0x7F,0x1C,0x00}, // 0xD1 |
{0x46,0x7D,0x7D,0x55,0x55,0x46,0x00,0x00}, // 0xD2 |
{0x45,0x7D,0x7C,0x54,0x55,0x45,0x00,0x00}, // 0xD3 |
{0x44,0x7D,0x7F,0x56,0x54,0x44,0x00,0x00}, // 0xD4 |
{0x0A,0x0E,0x08,0x00,0x00,0x00,0x00,0x00}, // 0xD5 |
{0x00,0x44,0x7E,0x7F,0x45,0x00,0x00,0x00}, // 0xD6 |
{0x02,0x45,0x7D,0x7D,0x45,0x02,0x00,0x00}, // 0xD7 |
{0x01,0x45,0x7C,0x7C,0x45,0x01,0x00,0x00}, // 0xD8 |
{0x10,0x10,0x10,0x1F,0x1F,0x00,0x00,0x00}, // 0xD9 |
{0x00,0x00,0x00,0xF0,0xF0,0x10,0x10,0x10}, // 0xDA |
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, // 0xDB |
{0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0}, // 0xDC |
{0x00,0x00,0x00,0x77,0x77,0x00,0x00,0x00}, // 0xDD |
{0x00,0x45,0x7F,0x7E,0x44,0x00,0x00,0x00}, // 0xDE |
{0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F}, // 0xDF |
{0x38,0x7C,0x46,0x47,0x45,0x7C,0x38,0x00}, // 0xE0 |
{0xFC,0xFE,0x2A,0x2A,0x3E,0x14,0x00,0x00}, // 0xE1 |
{0x3A,0x7D,0x45,0x45,0x45,0x7D,0x3A,0x00}, // 0xE2 |
{0x38,0x7C,0x45,0x47,0x46,0x7C,0x38,0x00}, // 0xE3 |
{0x32,0x7B,0x49,0x4B,0x7A,0x33,0x01,0x00}, // 0xE4 |
{0x3A,0x7F,0x45,0x47,0x46,0x7F,0x39,0x00}, // 0xE5 |
{0x80,0xFE,0x7E,0x20,0x20,0x3E,0x1E,0x00}, // 0xE6 |
{0x42,0x7E,0x7E,0x54,0x1C,0x08,0x00,0x00}, // 0xE7 |
{0x41,0x7F,0x7F,0x55,0x14,0x1C,0x08,0x00}, // 0xE8 |
{0x3C,0x7C,0x42,0x43,0x7D,0x3C,0x00,0x00}, // 0xE9 |
{0x3A,0x79,0x41,0x41,0x79,0x3A,0x00,0x00}, // 0xEA |
{0x3C,0x7D,0x43,0x42,0x7C,0x3C,0x00,0x00}, // 0xEB |
{0xB8,0xB8,0xA2,0xA3,0xF9,0x78,0x00,0x00}, // 0xEC |
{0x0C,0x5C,0x72,0x73,0x5D,0x0C,0x00,0x00}, // 0xED |
{0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00}, // 0xEE |
{0x00,0x00,0x02,0x03,0x01,0x00,0x00,0x00}, // 0xEF |
{0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00}, // 0xF0 |
{0x44,0x44,0x5F,0x5F,0x44,0x44,0x00,0x00}, // 0xF1 |
{0x28,0x28,0x28,0x28,0x28,0x28,0x00,0x00}, // 0xF2 |
{0x71,0x35,0x1F,0x4C,0x66,0x73,0xD9,0xF8}, // 0xF3 |
{0x06,0x0F,0x09,0x7F,0x7F,0x01,0x7F,0x7F}, // 0xF4 |
{0xDA,0xBF,0xA5,0xA5,0xFD,0x59,0x03,0x02}, // 0xF5 |
{0x08,0x08,0x6B,0x6B,0x08,0x08,0x00,0x00}, // 0xF6 |
{0x00,0x80,0xC0,0x40,0x00,0x00,0x00,0x00}, // 0xF7 |
{0x00,0x06,0x0F,0x09,0x0F,0x06,0x00,0x00}, // 0xF8 |
{0x02,0x02,0x00,0x00,0x02,0x02,0x00,0x00}, // 0xF9 |
{0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x00}, // 0xFA |
{0x00,0x12,0x13,0x1F,0x1F,0x10,0x10,0x00}, // 0xFB |
{0x00,0x11,0x15,0x15,0x1F,0x1F,0x0A,0x00}, // 0xFC |
{0x00,0x19,0x1D,0x15,0x17,0x12,0x00,0x00}, // 0xFD |
{0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00}, // 0xFE |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF |
}; |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/Font8x8.h |
---|
0,0 → 1,31 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _FONT8X8_H |
#define _FONT8X8_H |
#include <avr/pgmspace.h> |
extern const uint8_t Font8x8[256][8]; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/font8x6.c |
---|
0,0 → 1,172 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/pgmspace.h> |
// one byte is a column |
// bit 7 is the bottom |
// |
// 123456 |
// L 1 | XXX | |
// O 2 |X X | |
// W 4 |X X | |
// 8 | XXX | |
// H 1 |X X | |
// I 2 |X X | |
// G 4 | XXX | |
// H 8 | | |
// |
// 0x36,0x49,0x49,0x49,0x36,0x00 |
// |
//prog_uint8_t font8x6[128][6] = // führt zu Fehler mit AVR-GCC 4.5.1 21.2.2012 Cebra |
const uint8_t font8x6[128][6] PROGMEM = |
{ |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 0 00 (not useable) |
{ 0x78,0x15,0x14,0x15,0x78,0x00 }, // ASCII - 1 01 'Ä' |
{ 0x20,0x55,0x54,0x55,0x78,0x00 }, // ASCII - 2 02 'ä' |
{ 0x38,0x45,0x44,0x45,0x38,0x00 }, // ASCII - 3 03 'Ö' |
{ 0x30,0x49,0x48,0x49,0x30,0x00 }, // ASCII - 4 04 'ö' |
{ 0x3c,0x41,0x40,0x41,0x3c,0x00 }, // ASCII - 5 05 'Ü' |
{ 0x38,0x41,0x40,0x21,0x78,0x00 }, // ASCII - 6 06 'ü' |
{ 0x7e,0x15,0x15,0x15,0x0a,0x00 }, // ASCII - 7 07 'ß' |
{ 0x22,0x17,0x0F,0x17,0x22,0x00 }, // ASCII - 8 08 SAT Symbol |
{ 0x00,0x84,0x82,0xFF,0x82,0x84 }, // ASCII - 9 09 Altitude Symbol |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 10 0A (not useable) |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 11 0B |
{ 0x10,0x38,0x54,0x10,0x10,0x1e }, // ASCII - 12 0C Enter Symbol |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 13 0D (not useable) |
{ 0x10,0x10,0x10,0x10,0x10,0x10 }, // ASCII - 14 0E hor. line |
{ 0x10,0x10,0x10,0x7c,0x10,0x10 }, // ASCII - 15 0F hor. line with tick mark |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 16 10 |
{ 0x08,0x14,0x00,0x00,0x14,0x08 }, // ASCII - 17 11 <> Change |
{ 0x10,0x08,0x04,0x04,0x08,0x10 }, // ASCII - 18 12 /\ Up |
{ 0x08,0x10,0x20,0x20,0x10,0x08 }, // ASCII - 19 13 \/ Down |
{ 0x00,0x08,0x14,0x22,0x41,0x00 }, // ASCII - 20 14 < Left |
{ 0x00,0x41,0x22,0x14,0x08,0x00 }, // ASCII - 21 15 > Right |
{ 0x04,0x02,0x7f,0x02,0x04,0x00 }, // ASCII - 22 16 /|\ Arrow up |
{ 0x10,0x20,0x7f,0x20,0x10,0x00 }, // ASCII - 23 17 \|/ Arrow down |
{ 0x10,0x38,0x54,0x10,0x10,0x10 }, // ASCII - 24 18 <- Arrow left |
{ 0x10,0x10,0x10,0x54,0x38,0x10 }, // ASCII - 25 19 -> Arrow right |
{ 0x10,0x18,0x1c,0x1c,0x18,0x10 }, // ASCII - 26 1A ^ Triangle up |
{ 0x08,0x18,0x38,0x38,0x18,0x08 }, // ASCII - 27 1B v Triangle down |
{ 0x00,0x08,0x1c,0x3e,0x7f,0x00 }, // ASCII - 28 1C < Triangle left |
{ 0x00,0x7f,0x3e,0x1c,0x08,0x00 }, // ASCII - 29 1D > Triangle right |
{ 0x06,0x09,0x09,0x09,0x06,0x00 }, // ASCII - 30 1E '°' |
{ 0x06,0x49,0x7d,0x49,0x06,0x00 }, // ASCII - 31 1F Antenne |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 32 20 ' ' |
{ 0x00,0x00,0x2f,0x00,0x00,0x00 }, // ASCII - 33 21 '!' |
{ 0x00,0x07,0x00,0x07,0x00,0x00 }, // ASCII - 34 22 '"' |
{ 0x14,0x7f,0x14,0x7f,0x14,0x00 }, // ASCII - 35 23 '#' |
{ 0x24,0x2a,0x6b,0x2a,0x12,0x00 }, // ASCII - 36 24 '$' |
{ 0x23,0x13,0x08,0x64,0x62,0x00 }, // ASCII - 37 25 '%' |
{ 0x36,0x49,0x55,0x22,0x50,0x00 }, // ASCII - 38 26 '&' |
{ 0x00,0x05,0x03,0x00,0x00,0x00 }, // ASCII - 39 27 ''' |
{ 0x00,0x1c,0x22,0x41,0x00,0x00 }, // ASCII - 40 28 '(' |
{ 0x00,0x41,0x22,0x1c,0x00,0x00 }, // ASCII - 41 29 ')' |
{ 0x14,0x08,0x3e,0x08,0x14,0x00 }, // ASCII - 42 2a '*' |
{ 0x08,0x08,0x3e,0x08,0x08,0x00 }, // ASCII - 43 2b '+' |
{ 0x00,0x50,0x30,0x00,0x00,0x00 }, // ASCII - 44 2c ',' |
{ 0x08,0x08,0x08,0x08,0x08,0x00 }, // ASCII - 45 2d '-' |
{ 0x00,0x60,0x60,0x00,0x00,0x00 }, // ASCII - 46 2e '.' |
{ 0x20,0x10,0x08,0x04,0x02,0x00 }, // ASCII - 47 2f '/' |
{ 0x3e,0x51,0x49,0x45,0x3e,0x00 }, // ASCII - 48 30 '0' |
{ 0x00,0x42,0x7f,0x40,0x00,0x00 }, // ASCII - 49 31 '1' |
{ 0x42,0x61,0x51,0x49,0x46,0x00 }, // ASCII - 50 32 '2' |
{ 0x21,0x41,0x45,0x4b,0x31,0x00 }, // ASCII - 51 33 '3' |
{ 0x18,0x14,0x12,0x7f,0x10,0x00 }, // ASCII - 52 34 '4' |
{ 0x27,0x45,0x45,0x45,0x39,0x00 }, // ASCII - 53 35 '5' |
{ 0x3c,0x4a,0x49,0x49,0x30,0x00 }, // ASCII - 54 36 '6' |
{ 0x03,0x01,0x71,0x09,0x07,0x00 }, // ASCII - 55 37 '7' |
{ 0x36,0x49,0x49,0x49,0x36,0x00 }, // ASCII - 56 38 '8' |
{ 0x06,0x49,0x49,0x29,0x1e,0x00 }, // ASCII - 57 39 '9' |
{ 0x00,0x36,0x36,0x00,0x00,0x00 }, // ASCII - 58 3a ':' |
{ 0x00,0x56,0x36,0x00,0x00,0x00 }, // ASCII - 59 3b ';' |
{ 0x08,0x14,0x22,0x41,0x00,0x00 }, // ASCII - 60 3c '<' |
{ 0x14,0x14,0x14,0x14,0x14,0x00 }, // ASCII - 61 3d '=' |
{ 0x00,0x41,0x22,0x14,0x08,0x00 }, // ASCII - 62 3e '>' |
{ 0x02,0x01,0x51,0x09,0x06,0x00 }, // ASCII - 63 3f '?' |
{ 0x32,0x49,0x79,0x41,0x3e,0x00 }, // ASCII - 64 40 '@' |
{ 0x7e,0x11,0x11,0x11,0x7e,0x00 }, // ASCII - 65 41 'A' |
{ 0x7f,0x49,0x49,0x49,0x36,0x00 }, // ASCII - 66 42 'B' |
{ 0x3e,0x41,0x41,0x41,0x22,0x00 }, // ASCII - 67 43 'C' |
{ 0x7f,0x41,0x41,0x22,0x1c,0x00 }, // ASCII - 68 44 'D' |
{ 0x7f,0x49,0x49,0x49,0x41,0x00 }, // ASCII - 69 45 'E' |
{ 0x7f,0x09,0x09,0x09,0x01,0x00 }, // ASCII - 70 46 'F' |
{ 0x3e,0x41,0x49,0x49,0x7a,0x00 }, // ASCII - 71 47 'G' |
{ 0x7f,0x08,0x08,0x08,0x7f,0x00 }, // ASCII - 72 48 'H' |
{ 0x00,0x41,0x7f,0x41,0x00,0x00 }, // ASCII - 73 49 'I' |
{ 0x20,0x40,0x41,0x3f,0x01,0x00 }, // ASCII - 74 4a 'J' |
{ 0x7f,0x08,0x14,0x22,0x41,0x00 }, // ASCII - 75 4b 'K' |
{ 0x7f,0x40,0x40,0x40,0x40,0x00 }, // ASCII - 76 4c 'L' |
{ 0x7f,0x02,0x0c,0x02,0x7f,0x00 }, // ASCII - 77 4d 'M' |
{ 0x7f,0x04,0x08,0x10,0x7f,0x00 }, // ASCII - 78 4e 'N' |
{ 0x3e,0x41,0x41,0x41,0x3e,0x00 }, // ASCII - 79 4f 'O' |
{ 0x7f,0x09,0x09,0x09,0x06,0x00 }, // ASCII - 80 50 'P' |
{ 0x3e,0x41,0x51,0x21,0x5e,0x00 }, // ASCII - 81 51 'Q' |
{ 0x7f,0x09,0x19,0x29,0x46,0x00 }, // ASCII - 82 52 'R' |
{ 0x46,0x49,0x49,0x49,0x31,0x00 }, // ASCII - 83 53 'S' |
{ 0x01,0x01,0x7f,0x01,0x01,0x00 }, // ASCII - 84 54 'T' |
{ 0x3f,0x40,0x40,0x40,0x3f,0x00 }, // ASCII - 85 55 'U' |
{ 0x1f,0x20,0x40,0x20,0x1f,0x00 }, // ASCII - 86 56 'V' |
{ 0x3f,0x40,0x38,0x40,0x3f,0x00 }, // ASCII - 87 57 'W' |
{ 0x63,0x14,0x08,0x14,0x63,0x00 }, // ASCII - 88 58 'X' |
{ 0x07,0x08,0x70,0x08,0x07,0x00 }, // ASCII - 89 59 'Y' |
{ 0x61,0x51,0x49,0x45,0x43,0x00 }, // ASCII - 90 5a 'Z' |
{ 0x7f,0x41,0x41,0x00,0x00,0x00 }, // ASCII - 91 5b '[' |
{ 0x02,0x04,0x08,0x10,0x20,0x00 }, // ASCII - 92 5c '\' |
{ 0x00,0x41,0x41,0x7f,0x00,0x00 }, // ASCII - 93 5d ']' |
{ 0x04,0x02,0x01,0x02,0x04,0x00 }, // ASCII - 94 5e '^' |
{ 0x40,0x40,0x40,0x40,0x40,0x00 }, // ASCII - 95 5f '_' |
{ 0x00,0x01,0x02,0x04,0x00,0x00 }, // ASCII - 96 60 '`' |
{ 0x20,0x54,0x54,0x54,0x78,0x00 }, // ASCII - 97 61 'a' |
{ 0x7f,0x48,0x44,0x44,0x38,0x00 }, // ASCII - 98 62 'b' |
{ 0x38,0x44,0x44,0x44,0x20,0x00 }, // ASCII - 99 63 'c' |
{ 0x38,0x44,0x44,0x48,0x7f,0x00 }, // ASCII - 100 64 'd' |
{ 0x38,0x54,0x54,0x54,0x18,0x00 }, // ASCII - 101 65 'e' |
{ 0x08,0x7e,0x09,0x01,0x02,0x00 }, // ASCII - 102 66 'f' |
{ 0x0c,0x52,0x52,0x52,0x3e,0x00 }, // ASCII - 103 67 'g' |
{ 0x7f,0x08,0x04,0x04,0x78,0x00 }, // ASCII - 104 68 'h' |
{ 0x00,0x44,0x7d,0x40,0x00,0x00 }, // ASCII - 105 69 'i' |
{ 0x20,0x40,0x44,0x3d,0x00,0x00 }, // ASCII - 106 6a 'j' |
{ 0x7f,0x10,0x28,0x44,0x00,0x00 }, // ASCII - 107 6b 'k' |
{ 0x00,0x41,0x7f,0x40,0x00,0x00 }, // ASCII - 108 6c 'l' |
{ 0x7c,0x04,0x18,0x04,0x78,0x00 }, // ASCII - 109 6d 'm' |
{ 0x7c,0x08,0x04,0x04,0x78,0x00 }, // ASCII - 110 6e 'n' |
{ 0x38,0x44,0x44,0x44,0x38,0x00 }, // ASCII - 111 6f 'o' |
{ 0x7c,0x14,0x14,0x14,0x08,0x00 }, // ASCII - 112 70 'p' |
{ 0x08,0x14,0x14,0x18,0x7c,0x00 }, // ASCII - 113 71 'q' |
{ 0x7c,0x08,0x04,0x04,0x08,0x00 }, // ASCII - 114 72 'r' |
{ 0x48,0x54,0x54,0x54,0x20,0x00 }, // ASCII - 115 73 's' |
{ 0x04,0x3f,0x44,0x40,0x20,0x00 }, // ASCII - 116 74 't' |
{ 0x3c,0x40,0x40,0x20,0x7c,0x00 }, // ASCII - 117 75 'u' |
{ 0x1c,0x20,0x40,0x20,0x1c,0x00 }, // ASCII - 118 76 'v' |
{ 0x3c,0x40,0x38,0x40,0x3c,0x00 }, // ASCII - 119 77 'w' |
{ 0x44,0x28,0x10,0x28,0x44,0x00 }, // ASCII - 120 78 'x' |
{ 0x0c,0x50,0x50,0x50,0x3c,0x00 }, // ASCII - 121 79 'y' |
{ 0x44,0x64,0x54,0x4c,0x44,0x00 }, // ASCII - 122 7a 'z' |
{ 0x00,0x08,0x36,0x41,0x00,0x00 }, // ASCII - 123 7b '{' |
{ 0x00,0x00,0x7f,0x00,0x00,0x00 }, // ASCII - 124 7c '|' |
{ 0x00,0x41,0x36,0x08,0x00,0x00 }, // ASCII - 125 7d '}' |
{ 0x08,0x08,0x2a,0x1c,0x08,0x00 }, // ASCII - 126 7e -> |
{ 0x08,0x1c,0x2a,0x08,0x08,0x00 }, // ASCII - 127 7f <- |
}; |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/font8x6.h |
---|
0,0 → 1,30 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _FONT8X6_H |
#define _FONT8X6_H |
#include <avr/pgmspace.h> |
//extern prog_uint8_t font8x6[128][6]; |
extern const uint8_t font8x6[128][6]; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd/.directory |
---|
0,0 → 1,3 |
[Dolphin] |
Timestamp=2013,3,7,9,14,6 |
ViewMode=1 |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd/lcd.c |
---|
0,0 → 1,1402 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include "../cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include <math.h> |
#include "font8x6.h" |
#include "Font8x8.h" |
#include "../eeprom/eeprom.h" |
#include "lcd.h" |
#include "../main.h" |
#include "../HAL_HW3_9.h" |
#define DISP_W 128 |
#define DISP_H 64 |
#define DISP_BUFFER ((DISP_H * DISP_W) / 8) |
#define LINE_BUFFER (((DISP_H/8) * DISP_W) / 8) |
#define Jeti 1 // Jeti Routinen |
volatile uint8_t display_buffer[DISP_BUFFER]; // Display-Puffer, weil nicht zurückgelesen werden kann |
volatile uint8_t line_buffer[LINE_BUFFER]; // Zeilen-Puffer, weil nicht zurückgelesen werden kann |
volatile uint16_t display_buffer_pointer; // Pointer auf das aktuell übertragene Byte |
volatile uint8_t display_buffer_counter; // Hilfszähler zur Selektierung der Page |
volatile uint8_t display_page_counter; // aktuelle Page-Nummer |
volatile uint8_t display_mode; // Modus für State-Machine |
volatile uint8_t LCD_ORIENTATION; |
// DOG: 128 x 64 with 6x8 Font => 21 x 8 |
// MAX7456: 30 x 16 |
uint8_t lcd_xpos; |
uint8_t lcd_ypos; |
//----------------------------------------------------------- |
void send_byte (uint8_t data) |
{ |
clr_cs (); |
SPDR = data; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
// * Writes one command byte |
// * cmd - the command byte |
// |
void lcd_command(uint8_t cmd) |
{ |
// LCD_SELECT(); |
// LCD_CMD(); |
// spi_write(cmd); |
// LCD_UNSELECT(); |
clr_cs (); |
SPDR = cmd; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
void lcd_cls (void) |
{ |
uint16_t i, j; |
// memset (display_buffer, 0, 1024); |
for (i = 0; i < DISP_BUFFER; i++) |
display_buffer[i] = 0x00; |
for (i = 0; i < 8; i++) |
{ |
clr_A0 (); |
send_byte (0xB0 + i); //1011xxxx |
send_byte (0x10); //00010000 |
// send_byte(0x04); //00000100 gedreht plus 4 Byte |
// send_byte(0x00); //00000000 |
send_byte (LCD_ORIENTATION); //00000000 |
set_A0 (); |
for (j = 0; j < 128; j++) |
send_byte (0x00); |
} |
lcd_xpos = 0; |
lcd_ypos = 0; |
} |
//----------------------------------------------------------- |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w) |
{ |
uint8_t lcd_width; |
uint8_t lcd_zpos; |
uint8_t i; |
uint8_t max = 21; |
lcd_width = w; |
lcd_xpos = x; |
lcd_ypos = y; |
if ((lcd_xpos + lcd_width) > max) |
lcd_width = max - lcd_xpos; |
lcd_zpos = lcd_xpos + lcd_width; |
for (i = lcd_xpos; i < lcd_zpos; i++) |
lcd_putc (i, lcd_ypos, 0x20, 0); |
} |
//----------------------------------------------------------- |
void wait_1ms (void) |
{ |
_delay_ms (1); |
} |
//----------------------------------------------------------- |
void wait_ms (uint16_t time) |
{ |
uint16_t i; |
for (i = 0; i < time; i++) |
wait_1ms (); |
} |
//----------------------------------------------------------- |
void LCD_Init (uint8_t LCD_Mode) // LCD_Mode 0= Default Mode 1= EEPROM-Parameter) |
{ |
lcd_xpos = 0; |
lcd_ypos = 0; |
// DDRB = 0xFF; |
// SPI max. speed |
// the DOGM128 lcd controller can work at 20 MHz |
SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPHA) | (1 << CPOL); |
SPSR = (1 << SPI2X); |
set_cs (); |
clr_reset (); |
wait_ms (10); |
set_reset (); |
clr_cs (); |
clr_A0 (); |
send_byte (0x40); //Display start line = 0 |
if (LCD_Mode == 1) |
{ |
if (LCD_ORIENTATION == 0) |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
else |
{ |
send_byte (0xA0); // A1 normal A0 reverse(original) |
send_byte (0xC8); // C0 normal C8 reverse(original) |
} |
} |
else |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
if (LCD_Mode == 1) |
{ |
if (Config.LCD_DisplayMode == 0) |
send_byte (0xA6); //Display normal, not mirrored |
else |
send_byte (0xA7); //Display reverse, not mirrored |
} |
else |
send_byte (0xA6); |
send_byte (0xA2); //Set bias 1/9 (Duty 1/65) |
send_byte (0x2F); //Booster, regulator and follower on |
send_byte (0xF8); //Set internal booster to 4x |
send_byte (0x00); //Set internal booster to 4x |
send_byte (0x27); //resistor ratio set |
if (LCD_Mode == 1) |
{ |
send_byte (0x81); //Electronic volume register set |
send_byte (Config.LCD_Kontrast); //Electronic volume register set |
} |
else |
{ |
send_byte (0x81); |
send_byte (0x16); |
} |
send_byte (0xAC); //Cursor |
send_byte (0x00); //No Cursor |
send_byte (0xAF); //No indicator |
if (Config.HWSound==0) |
{ |
if (LCD_Mode == 1) |
{ |
// Helligkeit setzen |
OCR2A = Config.LCD_Helligkeit * 2.55; |
} |
else |
{ |
OCR2A = 255; |
} |
} |
lcd_cls (); |
} |
//----------------------------------------------------------- |
void set_adress (uint16_t adress, uint8_t data) |
{ |
uint8_t page; |
uint8_t column; |
page = adress >> 7; |
clr_A0 (); |
send_byte (0xB0 + page); |
column = (adress & 0x7F) + LCD_ORIENTATION; |
send_byte (0x10 + (column >> 4)); |
send_byte (column & 0x0F); |
set_A0 (); |
send_byte (data); |
} |
//----------------------------------------------------------- |
void scroll (void) |
{ |
uint16_t adress; |
for (adress = 0; adress < 896; adress++) |
{ |
display_buffer[adress] = display_buffer[adress + 128]; |
set_adress (adress, display_buffer[adress]); |
} |
for (adress = 896; adress < 1024; adress++) |
{ |
display_buffer[adress] = 0; |
set_adress (adress, 0); |
} |
} |
//----------------------------------------------------------- |
// sicher eine Zeile für die Statusanzeige |
void copy_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
line_buffer[i] = display_buffer[adress+i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
// holt gesicherte Zeile wieder zurück |
void paste_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
display_buffer[adress+i] =line_buffer[i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ) |
{ |
while (*s) |
{ |
lcd_putc(x, y, *s++, mode); |
x++; |
} |
}/* lcd_puts */ |
//----------------------------------------------------------- |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
if (mode == 2) |
lcd_frect ((x*6),(y*8),5,7,1); // invertierte Darstellung |
if (mode == 3) lcd_putc_jeti (x, y, c,0); |
else |
if (mode == 4) lcd_putc_jeti (x, y, c,2); |
else |
{ |
switch (c) |
{ // ISO 8859-1 |
case 0xc4: // Ä |
c = 0x01; |
break; |
case 0xe4: // ä |
c = 0x02; |
break; |
case 0xd6: // Ö |
c = 0x03; |
break; |
case 0xf6: // ö |
c = 0x04; |
break; |
case 0xdc: // Ü |
c = 0x05; |
break; |
case 0xfc: // ü |
c = 0x06; |
break; |
case 0xdf: // ß |
//c = 0x07; |
c = 0x1e; // ° (used by Jeti) |
break; |
} |
c &= 0x7f; |
adress = y * 128 + x * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6; i++) |
{ |
ch = pgm_read_byte (&font8x6[0][0] + i + c * 6); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
} |
#if Jeti |
//----------------------------------------------------------- |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
if (mode == 2) |
lcd_frect ((x*8),(y*8),8,8,1); // invertierte Darstellung |
switch (c) |
{ |
case 0x7e: |
c = 0x1a; // -> |
break; |
case 0x7f: |
c = 0x1b; // <- |
break; |
case 0xdf: |
c = 0xf8; // ° |
break; |
} |
adress = y * 128 + x * 8; |
adress &= 0x3FF; |
for (i = 0; i < 8; i++) |
{ |
ch = pgm_read_byte (&Font8x8[0][0] + i + c * 8); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
void lcd_printpj (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc_jeti (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpj (text, mode); |
} |
#endif |
//----------------------------------------------------------- |
void new_line (void) |
{ |
lcd_ypos++; |
if (lcd_ypos > 7) |
{ |
scroll (); |
lcd_ypos = 7; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
// new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpns (text, mode); |
} |
//----------------------------------------------------------- |
void lcd_printp (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printp (text, mode); |
} |
//----------------------------------------------------------- |
void lcd_print (uint8_t *text, uint8_t mode) |
{ |
while (*text) |
{ |
switch (*text) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, *text, mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_print (text, mode); |
} |
//----------------------------------------------------------- |
void print_display (uint8_t *text) |
{ |
while (*text) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, *text, 0); |
lcd_xpos++; |
if (lcd_xpos >= 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
print_display (text); |
} |
//----------------------------------------------------------- |
// + Plot (set one Pixel) |
//----------------------------------------------------------- |
// mode: |
// 0=Clear, 1=Set, 2=XOR |
void lcd_plot (uint8_t xpos, uint8_t ypos, uint8_t mode) |
{ |
uint16_t adress; |
uint8_t mask; |
if ((xpos < DISP_W) && (ypos < DISP_H)) |
{ |
adress = (ypos / 8) * DISP_W + xpos; // adress = 0/8 * 128 + 0 = 0 |
mask = 1 << (ypos & 0x07); // mask = 1<<0 = 1 |
adress &= DISP_BUFFER - 1; |
switch (mode) |
{ |
case 0: |
display_buffer[adress] &= ~mask; |
break; |
case 1: |
display_buffer[adress] |= mask; |
break; |
case 2: |
display_buffer[adress] ^= mask; |
break; |
} |
set_adress (adress, display_buffer[adress]); |
} |
} |
//----------------------------------------------------------- |
// + Line (draws a line from x1,y1 to x2,y2 |
// + Based on Bresenham line-Algorithm |
// + found in the internet, modified by thkais 2007 |
//----------------------------------------------------------- |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode) |
{ |
int x, y, count, xs, ys, xm, ym; |
x = (int) x1; |
y = (int) y1; |
xs = (int) x2 - (int) x1; |
ys = (int) y2 - (int) y1; |
if (xs < 0) |
xm = -1; |
else |
if (xs > 0) |
xm = 1; |
else |
xm = 0; |
if (ys < 0) |
ym = -1; |
else |
if (ys > 0) |
ym = 1; |
else |
ym = 0; |
if (xs < 0) |
xs = -xs; |
if (ys < 0) |
ys = -ys; |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
if (xs > ys) // Flat Line <45 degrees |
{ |
count = -(xs / 2); |
while (x != x2) |
{ |
count = count + ys; |
x = x + xm; |
if (count > 0) |
{ |
y = y + ym; |
count = count - xs; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
else // Line >=45 degrees |
{ |
count =- (ys / 2); |
while (y != y2) |
{ |
count = count + xs; |
y = y + ym; |
if (count > 0) |
{ |
x = x + xm; |
count = count - ys; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
} |
//----------------------------------------------------------- |
// + Filled rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
uint16_t i; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
for (i = y1; i <= y2; i++) |
{ |
lcd_line (x1, i, x2, i, mode); |
} |
} |
//----------------------------------------------------------- |
// + outline of rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
lcd_line (x1, y1, x2, y1, mode); |
lcd_line (x2, y1, x2, y2, mode); |
lcd_line (x2, y2, x1, y2, mode); |
lcd_line (x1, y2, x1, y1, mode); |
} |
//----------------------------------------------------------- |
// + outline of a circle |
// + Based on Bresenham-algorithm found in wikipedia |
// + modified by thkais (2007) |
//----------------------------------------------------------- |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_plot (x0, y0 + radius, mode); |
lcd_plot (x0, y0 - radius, mode); |
lcd_plot (x0 + radius, y0, mode); |
lcd_plot (x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y --; |
ddF_y += 2; |
f += ddF_y; |
} |
x ++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
lcd_plot (x0 + y, y0 + x, mode); |
lcd_plot (x0 - y, y0 + x, mode); |
lcd_plot (x0 + y, y0 - x, mode); |
lcd_plot (x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// + filled Circle |
// + modified circle-algorithm thkais (2007) |
//----------------------------------------------------------- |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius,uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_line (x0, y0 + radius, x0, y0 - radius, mode); |
lcd_line (x0 + radius, y0, x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y--; |
ddF_y += 2; |
f += ddF_y; |
} |
x++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_line (x0 + x, y0 + y, x0 - x, y0 + y, mode); |
lcd_line (x0 + x, y0 - y, x0 - x, y0 - y, mode); |
lcd_line (x0 + y, y0 + x, x0 - y, y0 + x, mode); |
lcd_line (x0 + y, y0 - x, x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) r); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) r); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) ry); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) rx); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode) |
{ |
const int16_t rx2 = rx * rx; |
const int16_t ry2 = ry * ry; |
int16_t F = round (ry2 - rx2 * ry + 0.25 * rx2); |
int16_t ddF_x = 0; |
int16_t ddF_y = 2 * rx2 * ry; |
int16_t x = 0; |
int16_t y = ry; |
lcd_plot (x0, y0 + ry, mode); |
lcd_plot (x0, y0 - ry, mode); |
lcd_plot (x0 + rx, y0, mode); |
lcd_plot (x0 - rx, y0, mode); |
// while ( 2*ry2*x < 2*rx2*y ) { we can use ddF_x and ddF_y |
while (ddF_x < ddF_y) |
{ |
if(F >= 0) |
{ |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F -= ddF_y; |
} |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x + ry2; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
F = round (ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2); |
while(y > 0) |
{ |
if(F <= 0) |
{ |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x; |
} |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F += rx2 - ddF_y; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
lcd_ellipse (x0, y0, radius + 3, radius, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
lcd_ellipse_line(x, y, r + 3, r, deg, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_view_font (uint8_t page) |
{ |
int x; |
int y; |
lcd_cls (); |
lcd_printp (PSTR(" 0123456789ABCDEF\r\n"), 0); |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Exit"), 0); |
lcd_ypos = 2; |
for (y = page * 4 ; y < (page * 4 + 4); y++) |
{ |
if (y < 10) |
{ |
lcd_putc (0, lcd_ypos, '0' + y, 0); |
} |
else |
{ |
lcd_putc (0, lcd_ypos, 'A' + y - 10, 0); |
} |
lcd_xpos = 2; |
for (x = 0; x < 16; x++) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, y * 16 + x, 0); |
lcd_xpos++; |
} |
lcd_ypos++; |
} |
} |
//----------------------------------------------------------- |
uint8_t hdigit (uint8_t d) |
{ |
if (d < 10) |
{ |
return '0' + d; |
} |
else |
{ |
return 'A' + d - 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos, lcd_ypos, hdigit (h & 0x0f), mode); |
} |
//----------------------------------------------------------- |
void lcd_print_hex (uint8_t h, uint8_t mode) |
{ |
// lcd_xpos = x; |
// lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h & 0x0f), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, ' ', mode); |
} |
//----------------------------------------------------------- |
void lcd_write_number_u (uint8_t number) |
{ |
uint8_t num = 100; |
uint8_t started = 0; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) |
{ |
lcd_putc (lcd_xpos++, lcd_ypos, '0' + b, 0); |
started = 1; |
} |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_write_number_u (number); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
utoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad==1) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', mode); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', mode); |
lcd_putc (x, y, '0', mode); |
} |
else |
{ |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', mode); |
lcd_putc (x++, y, rest, mode); |
} |
//----------------------------------------------------------- |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
uint8_t num = 100; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if ((num / 10) == 1) |
{ |
lcd_putc (x++, y, '.', 0); |
} |
lcd_putc (x++, y, '0' + b, 0); |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
itoa (number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', mode); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', mode); |
lcd_putc (x, y, '0', mode); |
} |
else |
{ |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', mode); |
lcd_putc (x++, y, rest, mode); |
} |
//----------------------------------------------------------- |
// write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
// |
void write_time (uint8_t x, uint8_t y, uint16_t seconds) |
{ |
uint16_t min = seconds / 60; |
seconds -= min * 60; |
write_ndigit_number_u (x, y, min, 2, 0,0); |
lcd_putc (x + 2, y, ':', 0); |
write_ndigit_number_u (x + 3, y, seconds, 2, 1,0); |
} |
//----------------------------------------------------------- |
// wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
// |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position) |
{ |
if (position < 0) |
{ |
position ^= ~0; |
position++; |
lcd_putc (x++, y, '-', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
write_ndigit_number_u (x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1,0); |
lcd_putc (x + 3, y, '.', 0); |
position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000); |
write_ndigit_number_u (x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1,0); |
position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000); |
write_ndigit_number_u (x + 8, y, (uint16_t) position, 3, 1,0); |
lcd_putc (x + 11, y, 0x1e, 0); // degree symbol |
} |
//------------------------------------------------------------------------------------ |
// Show PKT Baudrate at given position |
// |
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode) |
{ |
switch (Baudrate) |
{ |
case Baud_2400: lcd_printp_at (x, y, PSTR("2400"), mode);break; |
case Baud_4800: lcd_printp_at (x, y, PSTR("4800"), mode);break; |
case Baud_9600: lcd_printp_at (x, y, PSTR("9600"), mode);break; |
case Baud_19200: lcd_printp_at (x, y, PSTR("19200"), mode);break; |
case Baud_38400: lcd_printp_at (x, y, PSTR("38400"), mode);break; |
case Baud_57600: lcd_printp_at (x, y, PSTR("57600"), mode);break; |
case Baud_115200: lcd_printp_at (x, y, PSTR("115200"), mode);break; |
break; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd/lcd.h |
---|
0,0 → 1,282 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* Thanks to Oliver Schwaneberg for adding several functions to this library!* |
* * |
* Author: Jan Michel (jan at mueschelsoft dot de) * |
* License: GNU General Public License, version 3 * |
* Version: v0.93 September 2010 * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _LCD_H |
#define _LCD_H |
/* |
//----------------------------------------------------------------------------- |
// Command Codes |
//----------------------------------------------------------------------------- |
//1: Display on/off |
#define LCD_DISPLAY_ON 0xAF //switch display on |
#define LCD_DISPLAY_OFF 0xAE //switch display off |
//2: display start line set (lower 6 bits select first line on lcd from 64 lines in memory) |
#define LCD_START_LINE 0x40 |
//3: Page address set (lower 4 bits select one of 8 pages) |
#define LCD_PAGE_ADDRESS 0xB0 |
//4: column address (lower 4 bits are upper / lower nibble of column address) |
#define LCD_COL_ADDRESS_MSB 0x10 |
#define LCD_COL_ADDRESS_LSB 0x00 //second part of column address |
//8: select orientation (black side of the display should be further away from viewer) |
#define LCD_BOTTOMVIEW 0xA1 //6 o'clock view |
#define LCD_TOPVIEW 0xA0 //12 o'clock view |
//9: select normal (white background, black pixels) or reverse (black background, white pixels) mode |
#define LCD_DISPLAY_POSITIVE 0xA6 //not inverted mode |
#define LCD_DISPLAY_INVERTED 0xA7 //inverted display |
//10: show memory content or switch all pixels on |
#define LCD_SHOW_NORMAL 0xA4 //show dram content |
#define LCD_SHOW_ALL_POINTS 0xA5 //show all points |
//11: lcd bias set |
#define LCD_BIAS_1_9 0xA2 |
#define LCD_BIAS_1_7 0xA3 |
//14: Reset Controller |
#define LCD_RESET_CMD 0xE2 |
//15: output mode select (turns display upside-down) |
#define LCD_SCAN_DIR_NORMAL 0xC0 //normal scan direction |
#define LCD_SCAN_DIR_REVERSE 0xC8 //reversed scan direction |
//16: power control set (lower 3 bits select operating mode) |
//Bit 0: Voltage follower on/off - Bit 1: Voltage regulator on/off - Bit 2: Booster circuit on/off |
#define LCD_POWER_CONTROL 0x28 //base command |
#define LCD_POWER_LOW_POWER 0x2F |
#define LCD_POWER_WIDE_RANGE 0x2F |
#define LCD_POWER_LOW_VOLTAGE 0x2B |
//17: voltage regulator resistor ratio set (lower 3 bits select ratio) |
//selects lcd voltage - 000 is low (~ -2V), 111 is high (~ - 10V), also depending on volume mode. Datasheet suggests 011 |
#define LCD_VOLTAGE 0x20 |
//18: Volume mode set (2-byte command, lower 6 bits in second word select value, datasheet suggests 0x1F) |
#define LCD_VOLUME_MODE_1 0x81 |
#define LCD_VOLUME_MODE_2 0x00 |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
//19: static indicator (2-byte command), first on/off, then blinking mode |
#define LCD_INDICATOR_ON 0xAD //static indicator on |
#define LCD_INDICATOR_OFF 0xAC //static indicator off |
#define LCD_INDICATOR_MODE_OFF 0x00 |
#define LCD_INDICATOR_MODE_1HZ 0x01 |
#define LCD_INDICATOR_MODE_2HZ 0x10 |
#define LCD_INDICATOR_MODE_ON 0x11 |
//20: booster ratio set (2-byte command) |
#define LCD_BOOSTER_SET 0xF8 //set booster ratio |
#define LCD_BOOSTER_234 0x00 //2x-4x |
#define LCD_BOOSTER_5 0x01 //5x |
#define LCD_BOOSTER_6 0x03 //6x |
//#endif |
//22: NOP command |
#define LCD_NOP 0xE3 |
//#if DISPLAY_TYPE == 102 |
////25: advanced program control |
//#define LCD_ADV_PROG_CTRL 0xFA |
//#define LCD_ADV_PROG_CTRL2 0x10 |
//#endif |
//----------------------------------------------------------------------------- |
// Makros to execute commands |
//----------------------------------------------------------------------------- |
#define LCD_SWITCH_ON() lcd_command(LCD_DISPLAY_ON) |
#define LCD_SWITCH_OFF() lcd_command(LCD_DISPLAY_OFF) |
#define LCD_SET_FIRST_LINE(i) lcd_command(LCD_START_LINE | ((i) & 0x3F)) |
#define LCD_SET_PAGE_ADDR(i) lcd_command(LCD_PAGE_ADDRESS | ((i) & 0x0F)) |
#define LCD_SET_COLUMN_ADDR(i) lcd_command(LCD_COL_ADDRESS_MSB | ((i>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((i) & 0x0F)) |
#define LCD_GOTO_ADDRESS(page,col); lcd_command(LCD_PAGE_ADDRESS | ((page) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_MSB | ((col>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((col) & 0x0F)); |
#define LCD_SET_BOTTOM_VIEW() lcd_command(LCD_BOTTOMVIEW) |
#define LCD_SET_TOP_VIEW() lcd_command(LCD_TOPVIEW) |
#define LCD_SET_MODE_POSITIVE() lcd_command(LCD_DISPLAY_POSITIVE) |
#define LCD_SET_MODE_INVERTED() lcd_command(LCD_DISPLAY_INVERTED) |
#define LCD_SHOW_ALL_PIXELS_ON() lcd_command(LCD_SHOW_ALL_POINTS) |
#define LCD_SHOW_ALL_PIXELS_OFF() lcd_command(LCD_SHOW_NORMAL) |
#define LCD_SET_BIAS_RATIO_1_7() lcd_command(LCD_BIAS_1_7) |
#define LCD_SET_BIAS_RATIO_1_9() lcd_command(LCD_BIAS_1_9) |
#define LCD_SEND_RESET() lcd_command(LCD_RESET_CMD) |
#define LCD_ORIENTATION_NORMAL() lcd_command(LCD_SCAN_DIR_NORMAL) |
#define LCD_ORIENTATION_UPSIDEDOWN() lcd_command(LCD_SCAN_DIR_REVERSE) |
#define LCD_SET_POWER_CONTROL(i) lcd_command(LCD_POWER_CONTROL | ((i) & 0x07)) |
#define LCD_SET_LOW_POWER() lcd_command(LCD_POWER_LOW_POWER) |
#define LCD_SET_WIDE_RANGE() lcd_command(LCD_POWER_WIDE_RANGE) |
#define LCD_SET_LOW_VOLTAGE() lcd_command(LCD_POWER_LOW_VOLTAGE) |
#define LCD_SET_BIAS_VOLTAGE(i) lcd_command(LCD_VOLTAGE | ((i) & 0x07)) |
#define LCD_SET_VOLUME_MODE(i) lcd_command(LCD_VOLUME_MODE_1); \ |
lcd_command(LCD_VOLUME_MODE_2 | ((i) & 0x3F)) |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
#define LCD_SET_INDICATOR_OFF() lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_INDICATOR_MODE_OFF) |
#define LCD_SET_INDICATOR_STATIC() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_ON) |
#define LCD_SET_INDICATOR_1HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_1HZ) |
#define LCD_SET_INDICATOR_2HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_2HZ) |
#define LCD_SET_INDICATOR(i,j) lcd_command(LCD_INDICATOR_OFF | ((i) & 1)); \ |
lcd_command(((j) & 2)) |
#define LCD_SLEEP_MODE lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_DISPLAY_OFF); \ |
lcd_command(LCD_SHOW_ALL_POINTS) |
//#endif |
//#if DISPLAY_TYPE == 102 |
//#define LCD_TEMPCOMP_HIGH 0x80 |
//#define LCD_COLWRAP 0x02 |
//#define LCD_PAGEWRAP 0x01 |
//#define LCD_SET_ADV_PROG_CTRL(i) lcd_command(LCD_ADV_PROG_CTRL); |
// lcd_command(LCD_ADV_PROG_CTRL2 & i) |
//#endif |
*/ |
extern volatile uint8_t LCD_ORIENTATION; |
//#define LCD_LINES 8 |
//#define LCD_COLS 21 |
extern uint8_t lcd_xpos; |
extern uint8_t lcd_ypos; |
void lcd_command(uint8_t cmd); |
void send_byte (uint8_t data); |
void LCD_Init (uint8_t LCD_Mode); |
void new_line (void); |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ); |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void send_byte (uint8_t data); |
void lcd_print (uint8_t *text, uint8_t mode); |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode); |
void lcd_printp (const char *text, uint8_t mode); |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_printpns (const char *text, uint8_t mode); |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_cls (void); |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w); |
void print_display (uint8_t *text); |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text); |
void copy_line (uint8_t y); |
void paste_line (uint8_t y); |
// Jeti |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void lcd_printpj (const char *text, uint8_t mode); |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_plot (uint8_t x, uint8_t y, uint8_t mode); |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode); |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode); |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode); |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_view_font (uint8_t page); |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode); |
void lcd_write_number_u (uint8_t number); |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number); |
void lcd_print_hex (uint8_t h, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad,uint8_t mode); |
/** |
* Write only some digits of a signed <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /100th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* write <seconds> as human readable time at <x>/<y> |
*/ |
void write_time (uint8_t x, uint8_t y, uint16_t seconds); |
/** |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position); |
//------------------------------------------------------------------------------------ |
// Show PKT Baudrate at given position |
// |
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd.c |
---|
0,0 → 1,1453 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY lcd.c |
//# |
//# 07.03.2013 OG |
//# - del: Kompatibilitaetsfunktion lcd_printpj_at() entfernt |
//# |
//# 06.03.2013 OG |
//# - lcdx_putc() wurde erweitert mit Unterstuetzung des 8x8 Font (alte Jeti |
//# Funktionen) und Pixel-Verschiebung (xoffs,yoffs) |
//# - etliche Char basierte Funktionen wurden erweitert um Parameter xoffs,yoffs |
//# um die Ausgabe um +/- Pixel zu verschieben. Fuer Pixelgenaue Positionierung |
//# von OSD-Screen Elementen. |
//# Die neuen Funktionen mit Pixel-Verschiebung beginnen mit lcdx_, writex_ ... |
//# - add: Kompatibilitaet gewaehrleistet durch Mapper-Funktionen |
//# - add: defines fuer Char-Drawmode's (MNORMAL, MINVERS, MBIG, MBIGINVERS) |
//# - del: Jeti-Funktionen (teilweise ersetzt durch Kompatibilitaetsfunktionen) |
//############################################################################ |
#include "../cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include <math.h> |
#include "font8x6.h" |
#include "Font8x8.h" |
#include "../eeprom/eeprom.h" |
#include "lcd.h" |
#include "../main.h" |
#include "../HAL_HW3_9.h" |
#define DISP_W 128 |
#define DISP_H 64 |
#define DISP_BUFFER ((DISP_H * DISP_W) / 8) |
#define LINE_BUFFER (((DISP_H/8) * DISP_W) / 8) |
#define Jeti 1 // Jeti Routinen |
volatile uint8_t display_buffer[DISP_BUFFER]; // Display-Puffer, weil nicht zurückgelesen werden kann |
volatile uint8_t line_buffer[LINE_BUFFER]; // Zeilen-Puffer, weil nicht zurückgelesen werden kann |
volatile uint16_t display_buffer_pointer; // Pointer auf das aktuell übertragene Byte |
volatile uint8_t display_buffer_counter; // Hilfszähler zur Selektierung der Page |
volatile uint8_t display_page_counter; // aktuelle Page-Nummer |
volatile uint8_t display_mode; // Modus für State-Machine |
volatile uint8_t LCD_ORIENTATION; |
// DOG: 128 x 64 with 6x8 Font => 21 x 8 |
// MAX7456: 30 x 16 |
uint8_t lcd_xpos; |
uint8_t lcd_ypos; |
char s[7]; |
//----------------------------------------------------------- |
void send_byte (uint8_t data) |
{ |
clr_cs (); |
SPDR = data; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
// * Writes one command byte |
// * cmd - the command byte |
// |
void lcd_command(uint8_t cmd) |
{ |
// LCD_SELECT(); |
// LCD_CMD(); |
// spi_write(cmd); |
// LCD_UNSELECT(); |
clr_cs (); |
SPDR = cmd; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
void lcd_cls (void) |
{ |
uint16_t i, j; |
// memset (display_buffer, 0, 1024); |
for (i = 0; i < DISP_BUFFER; i++) |
display_buffer[i] = 0x00; |
for (i = 0; i < 8; i++) |
{ |
clr_A0 (); |
send_byte (0xB0 + i); //1011xxxx |
send_byte (0x10); //00010000 |
// send_byte(0x04); //00000100 gedreht plus 4 Byte |
// send_byte(0x00); //00000000 |
send_byte (LCD_ORIENTATION); //00000000 |
set_A0 (); |
for (j = 0; j < 128; j++) |
send_byte (0x00); |
} |
lcd_xpos = 0; |
lcd_ypos = 0; |
} |
//----------------------------------------------------------- |
void set_adress (uint16_t adress, uint8_t data) |
{ |
uint8_t page; |
uint8_t column; |
page = adress >> 7; |
clr_A0 (); |
send_byte (0xB0 + page); |
column = (adress & 0x7F) + LCD_ORIENTATION; |
send_byte (0x10 + (column >> 4)); |
send_byte (column & 0x0F); |
set_A0 (); |
send_byte (data); |
} |
//----------------------------------------------------------- |
void scroll (void) |
{ |
uint16_t adress; |
for (adress = 0; adress < 896; adress++) |
{ |
display_buffer[adress] = display_buffer[adress + 128]; |
set_adress (adress, display_buffer[adress]); |
} |
for (adress = 896; adress < 1024; adress++) |
{ |
display_buffer[adress] = 0; |
set_adress (adress, 0); |
} |
} |
//#################################################################################### |
//#################################################################################### |
//----------------------------------------------------------- |
// + Plot (set one Pixel) |
//----------------------------------------------------------- |
// mode: |
// 0=Clear, 1=Set, 2=XOR |
void lcd_plot (uint8_t xpos, uint8_t ypos, uint8_t mode) |
{ |
uint16_t adress; |
uint8_t mask; |
if ((xpos < DISP_W) && (ypos < DISP_H)) |
{ |
adress = (ypos / 8) * DISP_W + xpos; // adress = 0/8 * 128 + 0 = 0 |
mask = 1 << (ypos & 0x07); // mask = 1<<0 = 1 |
adress &= DISP_BUFFER - 1; |
switch (mode) |
{ |
case 0: |
display_buffer[adress] &= ~mask; |
break; |
case 1: |
display_buffer[adress] |= mask; |
break; |
case 2: |
display_buffer[adress] ^= mask; |
break; |
} |
set_adress (adress, display_buffer[adress]); |
} |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcdx_putc( uint8_t x, uint8_t y, uint8_t c, uint8_t mode, int8_t xoffs, int8_t yoffs ) |
{ |
uint8_t ch; |
uint16_t adress; |
uint8_t x1,y1; |
uint8_t x0,y0; |
uint8_t xw; |
uint8_t mask; |
uint8_t bit; |
uint8_t *font; |
//------------------------ |
// char translate |
//------------------------ |
switch (c) |
{ // ISO 8859-1 |
case 0xc4: c = 0x01; break; // Ä |
case 0xe4: c = 0x02; break; // ä |
case 0xd6: c = 0x03; break; // Ö |
case 0xf6: c = 0x04; break; // ö |
case 0xdc: c = 0x05; break; // Ü |
case 0xfc: c = 0x06; break; // ü |
case 0xdf: c = 0x1e; break; // ß c = 0x07; ° (used by Jeti) |
} |
c &= 0x7f; |
//------------------------ |
// Font Parameter setzen |
//------------------------ |
if( mode <=2 ) // normaler font (8x6) |
{ |
font = (uint8_t *) &font8x6[0][0]; |
xw = 6; |
} |
else // grosser font (8x8) |
{ |
font = (uint8_t *) &Font8x8[0][0]; |
xw = 8; |
} |
//------------------------ |
//------------------------ |
x0 = (x*xw) + xoffs; |
y0 = (y*8) + yoffs; |
if( yoffs == 0) |
{ |
//---------------------------------------------------------- |
// orginaler Character Algo |
// |
// funktioniert auch mit x Verschiebung aber nicht |
// mit y Verschiebung. |
// |
// Da 8 Bit aufeinmal gesetzt werden ist dieser Algo |
// bzgl. Geschwindigkeit effektiver als der Y-Algo. |
//---------------------------------------------------------- |
if( mode==MINVERS || mode==MBIGINVERS ) |
lcd_frect( (x*xw)+xoffs, (y*8), xw-1, 7, 1); // invertierte Darstellung |
adress = y * 128 + x * xw + xoffs; |
adress &= 0x3FF; |
for( x1 = 0; x1 < xw; x1++) |
{ |
ch = pgm_read_byte (font + x1 + c * xw); |
if( mode==MINVERS || mode==MBIGINVERS ) |
display_buffer[adress + x1] ^= ch; |
else |
display_buffer[adress + x1] = ch; |
set_adress (adress + x1, display_buffer[adress + x1]); |
} |
} |
else |
{ |
//---------------------------------------------------------- |
// Y-Algo |
// neuer Character Algo (nur wenn Pixel y-Verschiebung) |
//---------------------------------------------------------- |
for( x1 = 0; x1 < xw; x1++ ) |
{ |
ch = pgm_read_byte (font + x1 + c * xw); |
mask = 1; |
for( y1 = 0; y1 < 8; y1++ ) |
{ |
bit = (ch & mask); |
if( bit ) |
lcd_plot( x0+x1, y0+y1, ( (mode==MINVERS || mode==MBIGINVERS) ? 0 : 1) ); |
else |
lcd_plot( x0+x1, y0+y1, ( (mode==MINVERS || mode==MBIGINVERS) ? 1 : 0) ); |
mask = (mask << 1); |
} |
} |
} |
} |
//----------------------------------------------------------- |
//--- Kompatibilitaet |
//----------------------------------------------------------- |
void lcd_putc( uint8_t x, uint8_t y, uint8_t c, uint8_t mode ) |
{ |
lcdx_putc( x, y, c, mode, 0,0 ); |
} |
//#################################################################################### |
//#################################################################################### |
//----------------------------------------------------------- |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w) |
{ |
uint8_t lcd_width; |
uint8_t lcd_zpos; |
uint8_t i; |
uint8_t max = 21; |
lcd_width = w; |
lcd_xpos = x; |
lcd_ypos = y; |
if ((lcd_xpos + lcd_width) > max) |
lcd_width = max - lcd_xpos; |
lcd_zpos = lcd_xpos + lcd_width; |
for (i = lcd_xpos; i < lcd_zpos; i++) |
lcd_putc (i, lcd_ypos, 0x20, 0); |
} |
//----------------------------------------------------------- |
void wait_1ms (void) |
{ |
_delay_ms (1); |
} |
//----------------------------------------------------------- |
void wait_ms (uint16_t time) |
{ |
uint16_t i; |
for (i = 0; i < time; i++) |
wait_1ms (); |
} |
//----------------------------------------------------------- |
void LCD_Init (uint8_t LCD_Mode) // LCD_Mode 0= Default Mode 1= EEPROM-Parameter) |
{ |
lcd_xpos = 0; |
lcd_ypos = 0; |
// DDRB = 0xFF; |
// SPI max. speed |
// the DOGM128 lcd controller can work at 20 MHz |
SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPHA) | (1 << CPOL); |
SPSR = (1 << SPI2X); |
set_cs (); |
clr_reset (); |
wait_ms (10); |
set_reset (); |
clr_cs (); |
clr_A0 (); |
send_byte (0x40); //Display start line = 0 |
if (LCD_Mode == 1) |
{ |
if (LCD_ORIENTATION == 0) |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
else |
{ |
send_byte (0xA0); // A1 normal A0 reverse(original) |
send_byte (0xC8); // C0 normal C8 reverse(original) |
} |
} |
else |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
if (LCD_Mode == 1) |
{ |
if (Config.LCD_DisplayMode == 0) |
send_byte (0xA6); //Display normal, not mirrored |
else |
send_byte (0xA7); //Display reverse, not mirrored |
} |
else |
send_byte (0xA6); |
send_byte (0xA2); //Set bias 1/9 (Duty 1/65) |
send_byte (0x2F); //Booster, regulator and follower on |
send_byte (0xF8); //Set internal booster to 4x |
send_byte (0x00); //Set internal booster to 4x |
send_byte (0x27); //resistor ratio set |
if (LCD_Mode == 1) |
{ |
send_byte (0x81); //Electronic volume register set |
send_byte (Config.LCD_Kontrast); //Electronic volume register set |
} |
else |
{ |
send_byte (0x81); |
send_byte (0x16); |
} |
send_byte (0xAC); //Cursor |
send_byte (0x00); //No Cursor |
send_byte (0xAF); //No indicator |
if (Config.HWSound==0) |
{ |
if (LCD_Mode == 1) |
{ |
// Helligkeit setzen |
OCR2A = Config.LCD_Helligkeit * 2.55; |
} |
else |
{ |
OCR2A = 255; |
} |
} |
lcd_cls (); |
} |
//----------------------------------------------------------- |
// sicher eine Zeile für die Statusanzeige |
void copy_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
line_buffer[i] = display_buffer[adress+i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
// holt gesicherte Zeile wieder zurück |
void paste_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
display_buffer[adress+i] =line_buffer[i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcdx_puts_at( uint8_t x, uint8_t y, const char *s, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
while (*s) |
{ |
lcdx_putc(x, y, *s++, mode, xoffs,yoffs); |
x++; |
} |
}/* lcd_puts */ |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcd_puts_at( uint8_t x, uint8_t y, const char *s, uint8_t mode ) |
{ |
lcdx_puts_at( x, y, s, mode, 0,0 ); |
} |
//----------------------------------------------------------- |
void new_line (void) |
{ |
lcd_ypos++; |
if (lcd_ypos > 7) |
{ |
scroll (); |
lcd_ypos = 7; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
// new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpns (text, mode); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcdx_printp (const char *text, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
while( pgm_read_byte(text) ) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcdx_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode, xoffs,yoffs); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcd_printp (const char *text, uint8_t mode) |
{ |
lcdx_printp ( text, mode, 0,0); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcdx_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcdx_printp (text, mode, xoffs,yoffs); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcdx_printp_at ( x, y, text, mode, 0,0); |
} |
//----------------------------------------------------------- |
void lcdx_print (uint8_t *text, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
while (*text) |
{ |
switch (*text) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcdx_putc (lcd_xpos, lcd_ypos, *text, mode, xoffs,yoffs); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
//--- lcd_print: Kompatibilitaet |
//----------------------------------------------------------- |
void lcd_print (uint8_t *text, uint8_t mode ) |
{ |
lcdx_print (text, mode, 0,0 ); |
} |
//----------------------------------------------------------- |
void lcdx_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcdx_print (text, mode, xoffs, yoffs); |
} |
//----------------------------------------------------------- |
//--- lcd_print_at: Kompatibilitaet |
//----------------------------------------------------------- |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode ) |
{ |
lcdx_print_at ( x, y, text, mode, 0,0); |
} |
//----------------------------------------------------------- |
void print_display (uint8_t *text) |
{ |
while (*text) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, *text, 0); |
lcd_xpos++; |
if (lcd_xpos >= 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
print_display (text); |
} |
//----------------------------------------------------------- |
// + Line (draws a line from x1,y1 to x2,y2 |
// + Based on Bresenham line-Algorithm |
// + found in the internet, modified by thkais 2007 |
//----------------------------------------------------------- |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode) |
{ |
int x, y, count, xs, ys, xm, ym; |
x = (int) x1; |
y = (int) y1; |
xs = (int) x2 - (int) x1; |
ys = (int) y2 - (int) y1; |
if (xs < 0) |
xm = -1; |
else |
if (xs > 0) |
xm = 1; |
else |
xm = 0; |
if (ys < 0) |
ym = -1; |
else |
if (ys > 0) |
ym = 1; |
else |
ym = 0; |
if (xs < 0) |
xs = -xs; |
if (ys < 0) |
ys = -ys; |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
if (xs > ys) // Flat Line <45 degrees |
{ |
count = -(xs / 2); |
while (x != x2) |
{ |
count = count + ys; |
x = x + xm; |
if (count > 0) |
{ |
y = y + ym; |
count = count - xs; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
else // Line >=45 degrees |
{ |
count =- (ys / 2); |
while (y != y2) |
{ |
count = count + xs; |
y = y + ym; |
if (count > 0) |
{ |
x = x + xm; |
count = count - ys; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
} |
//----------------------------------------------------------- |
// + Filled rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
uint16_t i; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
for (i = y1; i <= y2; i++) |
{ |
lcd_line (x1, i, x2, i, mode); |
} |
} |
//----------------------------------------------------------- |
// + outline of rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
lcd_line (x1, y1, x2, y1, mode); |
lcd_line (x2, y1, x2, y2, mode); |
lcd_line (x2, y2, x1, y2, mode); |
lcd_line (x1, y2, x1, y1, mode); |
} |
//----------------------------------------------------------- |
// + outline of a circle |
// + Based on Bresenham-algorithm found in wikipedia |
// + modified by thkais (2007) |
//----------------------------------------------------------- |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_plot (x0, y0 + radius, mode); |
lcd_plot (x0, y0 - radius, mode); |
lcd_plot (x0 + radius, y0, mode); |
lcd_plot (x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y --; |
ddF_y += 2; |
f += ddF_y; |
} |
x ++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
lcd_plot (x0 + y, y0 + x, mode); |
lcd_plot (x0 - y, y0 + x, mode); |
lcd_plot (x0 + y, y0 - x, mode); |
lcd_plot (x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// + filled Circle |
// + modified circle-algorithm thkais (2007) |
//----------------------------------------------------------- |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius,uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_line (x0, y0 + radius, x0, y0 - radius, mode); |
lcd_line (x0 + radius, y0, x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y--; |
ddF_y += 2; |
f += ddF_y; |
} |
x++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_line (x0 + x, y0 + y, x0 - x, y0 + y, mode); |
lcd_line (x0 + x, y0 - y, x0 - x, y0 - y, mode); |
lcd_line (x0 + y, y0 + x, x0 - y, y0 + x, mode); |
lcd_line (x0 + y, y0 - x, x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) r); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) r); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) ry); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) rx); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode) |
{ |
const int16_t rx2 = rx * rx; |
const int16_t ry2 = ry * ry; |
int16_t F = round (ry2 - rx2 * ry + 0.25 * rx2); |
int16_t ddF_x = 0; |
int16_t ddF_y = 2 * rx2 * ry; |
int16_t x = 0; |
int16_t y = ry; |
lcd_plot (x0, y0 + ry, mode); |
lcd_plot (x0, y0 - ry, mode); |
lcd_plot (x0 + rx, y0, mode); |
lcd_plot (x0 - rx, y0, mode); |
// while ( 2*ry2*x < 2*rx2*y ) { we can use ddF_x and ddF_y |
while (ddF_x < ddF_y) |
{ |
if(F >= 0) |
{ |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F -= ddF_y; |
} |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x + ry2; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
F = round (ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2); |
while(y > 0) |
{ |
if(F <= 0) |
{ |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x; |
} |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F += rx2 - ddF_y; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
lcd_ellipse (x0, y0, radius + 3, radius, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
lcd_ellipse_line(x, y, r + 3, r, deg, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_view_font (uint8_t page) |
{ |
int x; |
int y; |
lcd_cls (); |
lcd_printp (PSTR(" 0123456789ABCDEF\r\n"), 0); |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Exit"), 0); |
lcd_ypos = 2; |
for (y = page * 4 ; y < (page * 4 + 4); y++) |
{ |
if (y < 10) |
{ |
lcd_putc (0, lcd_ypos, '0' + y, 0); |
} |
else |
{ |
lcd_putc (0, lcd_ypos, 'A' + y - 10, 0); |
} |
lcd_xpos = 2; |
for (x = 0; x < 16; x++) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, y * 16 + x, 0); |
lcd_xpos++; |
} |
lcd_ypos++; |
} |
} |
//----------------------------------------------------------- |
uint8_t hdigit (uint8_t d) |
{ |
if (d < 10) |
{ |
return '0' + d; |
} |
else |
{ |
return 'A' + d - 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos, lcd_ypos, hdigit (h & 0x0f), mode); |
} |
//----------------------------------------------------------- |
void lcd_print_hex (uint8_t h, uint8_t mode) |
{ |
// lcd_xpos = x; |
// lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h & 0x0f), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, ' ', mode); |
} |
//----------------------------------------------------------- |
void lcd_write_number_u (uint8_t number) |
{ |
uint8_t num = 100; |
uint8_t started = 0; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) |
{ |
lcd_putc (lcd_xpos++, lcd_ypos, '0' + b, 0); |
started = 1; |
} |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_write_number_u (number); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void writex_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
//char s[7]; |
utoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcdx_putc (x++, y, '*', mode, xoffs,yoffs); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad==1) |
{ |
lcdx_putc (x++, y, '0', mode, xoffs,yoffs); |
} |
else |
{ |
lcdx_putc (x++, y, ' ', mode, xoffs,yoffs); |
} |
} |
lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs,yoffs); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
writex_ndigit_number_u( x, y, number, length, pad, mode, 0,0); |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void writex_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
//char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcdx_putc (x++, y, '*', mode, xoffs,yoffs); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcdx_putc (x++, y, '0', mode, xoffs,yoffs); |
} |
else |
{ |
lcdx_putc (x++, y, ' ', mode, xoffs,yoffs); |
} |
} |
lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs,yoffs); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
writex_ndigit_number_s (x, y, number, length, pad, mode, 0,0); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void writex_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
//char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcdx_putc (x++, y, '*', mode, xoffs,yoffs); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcdx_putc (x++, y, '0', mode, xoffs,yoffs); |
} |
else |
{ |
lcdx_putc (x++, y, ' ', mode, xoffs,yoffs); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcdx_putc (x-1, y, '0', mode, xoffs,yoffs); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcdx_putc (x-1, y, '-', mode, xoffs,yoffs); |
lcdx_putc (x, y, '0', mode, xoffs,yoffs); |
} |
else |
{ |
lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs,yoffs); |
} |
x += len - 1; |
lcdx_putc (x++, y, '.', mode, xoffs,yoffs); |
lcdx_putc (x++, y, rest, mode, xoffs,yoffs); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
writex_ndigit_number_u_10th ( x, y, number, length, pad, mode, 0,0); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void writex_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, int8_t xoffs, int8_t yoffs) |
{ |
uint8_t num = 100; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if ((num / 10) == 1) |
{ |
lcdx_putc (x++, y, '.', 0, xoffs,yoffs); |
} |
lcdx_putc (x++, y, '0' + b, 0, xoffs,yoffs); |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
writex_ndigit_number_u_100th ( x, y, number, length, pad, 0,0); |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void writex_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
//char s[7]; |
itoa (number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcdx_putc (x++, y, '*', mode, xoffs, yoffs); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcdx_putc (x++, y, '0', mode, xoffs, yoffs); |
} |
else |
{ |
lcdx_putc (x++, y, ' ', mode, xoffs, yoffs); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcdx_putc (x-1, y, '0', mode, xoffs, yoffs); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcdx_putc (x-1, y, '-', mode, xoffs,yoffs); |
lcdx_putc (x, y, '0', mode, xoffs,yoffs); |
} |
else |
{ |
lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs, yoffs); |
} |
x += len - 1; |
lcdx_putc (x++, y, '.', mode, xoffs, yoffs); |
lcdx_putc (x++, y, rest, mode, xoffs, yoffs); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
writex_ndigit_number_s_10th ( x, y, number, length, pad, mode, 0,0); |
} |
//----------------------------------------------------------- |
// write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
// |
void writex_time (uint8_t x, uint8_t y, uint16_t seconds, uint8_t mode, int8_t xoffs, int8_t yoffs) |
{ |
uint16_t min = seconds / 60; |
seconds -= min * 60; |
writex_ndigit_number_u (x, y, min, 2, 0,mode, xoffs,yoffs); |
lcd_putc (x + 2, y, ':', 0); |
writex_ndigit_number_u (x + 3, y, seconds, 2, 1,mode, xoffs,yoffs); |
} |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
void write_time (uint8_t x, uint8_t y, uint16_t seconds) |
{ |
writex_time ( x, y, seconds, 0, 0,0); |
} |
//----------------------------------------------------------- |
// wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
// |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position) |
{ |
if (position < 0) |
{ |
position ^= ~0; |
position++; |
lcd_putc (x++, y, '-', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
write_ndigit_number_u (x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1,0); |
lcd_putc (x + 3, y, '.', 0); |
position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000); |
write_ndigit_number_u (x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1,0); |
position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000); |
write_ndigit_number_u (x + 8, y, (uint16_t) position, 3, 1,0); |
lcd_putc (x + 11, y, 0x1e, 0); // degree symbol |
} |
//------------------------------------------------------------------------------------ |
// Show PKT Baudrate at given position |
// |
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode) |
{ |
switch (Baudrate) |
{ |
case Baud_2400: lcd_printp_at (x, y, PSTR("2400"), mode);break; |
case Baud_4800: lcd_printp_at (x, y, PSTR("4800"), mode);break; |
case Baud_9600: lcd_printp_at (x, y, PSTR("9600"), mode);break; |
case Baud_19200: lcd_printp_at (x, y, PSTR("19200"), mode);break; |
case Baud_38400: lcd_printp_at (x, y, PSTR("38400"), mode);break; |
case Baud_57600: lcd_printp_at (x, y, PSTR("57600"), mode);break; |
case Baud_115200: lcd_printp_at (x, y, PSTR("115200"), mode);break; |
break; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd.cold |
---|
0,0 → 1,1402 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include "../cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include <math.h> |
#include "font8x6.h" |
#include "Font8x8.h" |
#include "../eeprom/eeprom.h" |
#include "lcd.h" |
#include "../main.h" |
#include "../HAL_HW3_9.h" |
#define DISP_W 128 |
#define DISP_H 64 |
#define DISP_BUFFER ((DISP_H * DISP_W) / 8) |
#define LINE_BUFFER (((DISP_H/8) * DISP_W) / 8) |
#define Jeti 1 // Jeti Routinen |
volatile uint8_t display_buffer[DISP_BUFFER]; // Display-Puffer, weil nicht zurückgelesen werden kann |
volatile uint8_t line_buffer[LINE_BUFFER]; // Zeilen-Puffer, weil nicht zurückgelesen werden kann |
volatile uint16_t display_buffer_pointer; // Pointer auf das aktuell übertragene Byte |
volatile uint8_t display_buffer_counter; // Hilfszähler zur Selektierung der Page |
volatile uint8_t display_page_counter; // aktuelle Page-Nummer |
volatile uint8_t display_mode; // Modus für State-Machine |
volatile uint8_t LCD_ORIENTATION; |
// DOG: 128 x 64 with 6x8 Font => 21 x 8 |
// MAX7456: 30 x 16 |
uint8_t lcd_xpos; |
uint8_t lcd_ypos; |
//----------------------------------------------------------- |
void send_byte (uint8_t data) |
{ |
clr_cs (); |
SPDR = data; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
// * Writes one command byte |
// * cmd - the command byte |
// |
void lcd_command(uint8_t cmd) |
{ |
// LCD_SELECT(); |
// LCD_CMD(); |
// spi_write(cmd); |
// LCD_UNSELECT(); |
clr_cs (); |
SPDR = cmd; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
void lcd_cls (void) |
{ |
uint16_t i, j; |
// memset (display_buffer, 0, 1024); |
for (i = 0; i < DISP_BUFFER; i++) |
display_buffer[i] = 0x00; |
for (i = 0; i < 8; i++) |
{ |
clr_A0 (); |
send_byte (0xB0 + i); //1011xxxx |
send_byte (0x10); //00010000 |
// send_byte(0x04); //00000100 gedreht plus 4 Byte |
// send_byte(0x00); //00000000 |
send_byte (LCD_ORIENTATION); //00000000 |
set_A0 (); |
for (j = 0; j < 128; j++) |
send_byte (0x00); |
} |
lcd_xpos = 0; |
lcd_ypos = 0; |
} |
//----------------------------------------------------------- |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w) |
{ |
uint8_t lcd_width; |
uint8_t lcd_zpos; |
uint8_t i; |
uint8_t max = 21; |
lcd_width = w; |
lcd_xpos = x; |
lcd_ypos = y; |
if ((lcd_xpos + lcd_width) > max) |
lcd_width = max - lcd_xpos; |
lcd_zpos = lcd_xpos + lcd_width; |
for (i = lcd_xpos; i < lcd_zpos; i++) |
lcd_putc (i, lcd_ypos, 0x20, 0); |
} |
//----------------------------------------------------------- |
void wait_1ms (void) |
{ |
_delay_ms (1); |
} |
//----------------------------------------------------------- |
void wait_ms (uint16_t time) |
{ |
uint16_t i; |
for (i = 0; i < time; i++) |
wait_1ms (); |
} |
//----------------------------------------------------------- |
void LCD_Init (uint8_t LCD_Mode) // LCD_Mode 0= Default Mode 1= EEPROM-Parameter) |
{ |
lcd_xpos = 0; |
lcd_ypos = 0; |
// DDRB = 0xFF; |
// SPI max. speed |
// the DOGM128 lcd controller can work at 20 MHz |
SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPHA) | (1 << CPOL); |
SPSR = (1 << SPI2X); |
set_cs (); |
clr_reset (); |
wait_ms (10); |
set_reset (); |
clr_cs (); |
clr_A0 (); |
send_byte (0x40); //Display start line = 0 |
if (LCD_Mode == 1) |
{ |
if (LCD_ORIENTATION == 0) |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
else |
{ |
send_byte (0xA0); // A1 normal A0 reverse(original) |
send_byte (0xC8); // C0 normal C8 reverse(original) |
} |
} |
else |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
if (LCD_Mode == 1) |
{ |
if (Config.LCD_DisplayMode == 0) |
send_byte (0xA6); //Display normal, not mirrored |
else |
send_byte (0xA7); //Display reverse, not mirrored |
} |
else |
send_byte (0xA6); |
send_byte (0xA2); //Set bias 1/9 (Duty 1/65) |
send_byte (0x2F); //Booster, regulator and follower on |
send_byte (0xF8); //Set internal booster to 4x |
send_byte (0x00); //Set internal booster to 4x |
send_byte (0x27); //resistor ratio set |
if (LCD_Mode == 1) |
{ |
send_byte (0x81); //Electronic volume register set |
send_byte (Config.LCD_Kontrast); //Electronic volume register set |
} |
else |
{ |
send_byte (0x81); |
send_byte (0x16); |
} |
send_byte (0xAC); //Cursor |
send_byte (0x00); //No Cursor |
send_byte (0xAF); //No indicator |
if (Config.HWSound==0) |
{ |
if (LCD_Mode == 1) |
{ |
// Helligkeit setzen |
OCR2A = Config.LCD_Helligkeit * 2.55; |
} |
else |
{ |
OCR2A = 255; |
} |
} |
lcd_cls (); |
} |
//----------------------------------------------------------- |
void set_adress (uint16_t adress, uint8_t data) |
{ |
uint8_t page; |
uint8_t column; |
page = adress >> 7; |
clr_A0 (); |
send_byte (0xB0 + page); |
column = (adress & 0x7F) + LCD_ORIENTATION; |
send_byte (0x10 + (column >> 4)); |
send_byte (column & 0x0F); |
set_A0 (); |
send_byte (data); |
} |
//----------------------------------------------------------- |
void scroll (void) |
{ |
uint16_t adress; |
for (adress = 0; adress < 896; adress++) |
{ |
display_buffer[adress] = display_buffer[adress + 128]; |
set_adress (adress, display_buffer[adress]); |
} |
for (adress = 896; adress < 1024; adress++) |
{ |
display_buffer[adress] = 0; |
set_adress (adress, 0); |
} |
} |
//----------------------------------------------------------- |
// sicher eine Zeile für die Statusanzeige |
void copy_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
line_buffer[i] = display_buffer[adress+i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
// holt gesicherte Zeile wieder zurück |
void paste_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
display_buffer[adress+i] =line_buffer[i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ) |
{ |
while (*s) |
{ |
lcd_putc(x, y, *s++, mode); |
x++; |
} |
}/* lcd_puts */ |
//----------------------------------------------------------- |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
if (mode == 2) |
lcd_frect ((x*6),(y*8),5,7,1); // invertierte Darstellung |
if (mode == 3) lcd_putc_jeti (x, y, c,0); |
else |
if (mode == 4) lcd_putc_jeti (x, y, c,2); |
else |
{ |
switch (c) |
{ // ISO 8859-1 |
case 0xc4: // Ä |
c = 0x01; |
break; |
case 0xe4: // ä |
c = 0x02; |
break; |
case 0xd6: // Ö |
c = 0x03; |
break; |
case 0xf6: // ö |
c = 0x04; |
break; |
case 0xdc: // Ü |
c = 0x05; |
break; |
case 0xfc: // ü |
c = 0x06; |
break; |
case 0xdf: // ß |
//c = 0x07; |
c = 0x1e; // ° (used by Jeti) |
break; |
} |
c &= 0x7f; |
adress = y * 128 + x * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6; i++) |
{ |
ch = pgm_read_byte (&font8x6[0][0] + i + c * 6); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
} |
#if Jeti |
//----------------------------------------------------------- |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
if (mode == 2) |
lcd_frect ((x*8),(y*8),8,8,1); // invertierte Darstellung |
switch (c) |
{ |
case 0x7e: |
c = 0x1a; // -> |
break; |
case 0x7f: |
c = 0x1b; // <- |
break; |
case 0xdf: |
c = 0xf8; // ° |
break; |
} |
adress = y * 128 + x * 8; |
adress &= 0x3FF; |
for (i = 0; i < 8; i++) |
{ |
ch = pgm_read_byte (&Font8x8[0][0] + i + c * 8); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
void lcd_printpj (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc_jeti (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpj (text, mode); |
} |
#endif |
//----------------------------------------------------------- |
void new_line (void) |
{ |
lcd_ypos++; |
if (lcd_ypos > 7) |
{ |
scroll (); |
lcd_ypos = 7; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
// new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpns (text, mode); |
} |
//----------------------------------------------------------- |
void lcd_printp (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printp (text, mode); |
} |
//----------------------------------------------------------- |
void lcd_print (uint8_t *text, uint8_t mode) |
{ |
while (*text) |
{ |
switch (*text) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, *text, mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_print (text, mode); |
} |
//----------------------------------------------------------- |
void print_display (uint8_t *text) |
{ |
while (*text) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, *text, 0); |
lcd_xpos++; |
if (lcd_xpos >= 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
print_display (text); |
} |
//----------------------------------------------------------- |
// + Plot (set one Pixel) |
//----------------------------------------------------------- |
// mode: |
// 0=Clear, 1=Set, 2=XOR |
void lcd_plot (uint8_t xpos, uint8_t ypos, uint8_t mode) |
{ |
uint16_t adress; |
uint8_t mask; |
if ((xpos < DISP_W) && (ypos < DISP_H)) |
{ |
adress = (ypos / 8) * DISP_W + xpos; // adress = 0/8 * 128 + 0 = 0 |
mask = 1 << (ypos & 0x07); // mask = 1<<0 = 1 |
adress &= DISP_BUFFER - 1; |
switch (mode) |
{ |
case 0: |
display_buffer[adress] &= ~mask; |
break; |
case 1: |
display_buffer[adress] |= mask; |
break; |
case 2: |
display_buffer[adress] ^= mask; |
break; |
} |
set_adress (adress, display_buffer[adress]); |
} |
} |
//----------------------------------------------------------- |
// + Line (draws a line from x1,y1 to x2,y2 |
// + Based on Bresenham line-Algorithm |
// + found in the internet, modified by thkais 2007 |
//----------------------------------------------------------- |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode) |
{ |
int x, y, count, xs, ys, xm, ym; |
x = (int) x1; |
y = (int) y1; |
xs = (int) x2 - (int) x1; |
ys = (int) y2 - (int) y1; |
if (xs < 0) |
xm = -1; |
else |
if (xs > 0) |
xm = 1; |
else |
xm = 0; |
if (ys < 0) |
ym = -1; |
else |
if (ys > 0) |
ym = 1; |
else |
ym = 0; |
if (xs < 0) |
xs = -xs; |
if (ys < 0) |
ys = -ys; |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
if (xs > ys) // Flat Line <45 degrees |
{ |
count = -(xs / 2); |
while (x != x2) |
{ |
count = count + ys; |
x = x + xm; |
if (count > 0) |
{ |
y = y + ym; |
count = count - xs; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
else // Line >=45 degrees |
{ |
count =- (ys / 2); |
while (y != y2) |
{ |
count = count + xs; |
y = y + ym; |
if (count > 0) |
{ |
x = x + xm; |
count = count - ys; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
} |
//----------------------------------------------------------- |
// + Filled rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
uint16_t i; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
for (i = y1; i <= y2; i++) |
{ |
lcd_line (x1, i, x2, i, mode); |
} |
} |
//----------------------------------------------------------- |
// + outline of rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
lcd_line (x1, y1, x2, y1, mode); |
lcd_line (x2, y1, x2, y2, mode); |
lcd_line (x2, y2, x1, y2, mode); |
lcd_line (x1, y2, x1, y1, mode); |
} |
//----------------------------------------------------------- |
// + outline of a circle |
// + Based on Bresenham-algorithm found in wikipedia |
// + modified by thkais (2007) |
//----------------------------------------------------------- |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_plot (x0, y0 + radius, mode); |
lcd_plot (x0, y0 - radius, mode); |
lcd_plot (x0 + radius, y0, mode); |
lcd_plot (x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y --; |
ddF_y += 2; |
f += ddF_y; |
} |
x ++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
lcd_plot (x0 + y, y0 + x, mode); |
lcd_plot (x0 - y, y0 + x, mode); |
lcd_plot (x0 + y, y0 - x, mode); |
lcd_plot (x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// + filled Circle |
// + modified circle-algorithm thkais (2007) |
//----------------------------------------------------------- |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius,uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_line (x0, y0 + radius, x0, y0 - radius, mode); |
lcd_line (x0 + radius, y0, x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y--; |
ddF_y += 2; |
f += ddF_y; |
} |
x++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_line (x0 + x, y0 + y, x0 - x, y0 + y, mode); |
lcd_line (x0 + x, y0 - y, x0 - x, y0 - y, mode); |
lcd_line (x0 + y, y0 + x, x0 - y, y0 + x, mode); |
lcd_line (x0 + y, y0 - x, x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) r); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) r); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) ry); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) rx); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode) |
{ |
const int16_t rx2 = rx * rx; |
const int16_t ry2 = ry * ry; |
int16_t F = round (ry2 - rx2 * ry + 0.25 * rx2); |
int16_t ddF_x = 0; |
int16_t ddF_y = 2 * rx2 * ry; |
int16_t x = 0; |
int16_t y = ry; |
lcd_plot (x0, y0 + ry, mode); |
lcd_plot (x0, y0 - ry, mode); |
lcd_plot (x0 + rx, y0, mode); |
lcd_plot (x0 - rx, y0, mode); |
// while ( 2*ry2*x < 2*rx2*y ) { we can use ddF_x and ddF_y |
while (ddF_x < ddF_y) |
{ |
if(F >= 0) |
{ |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F -= ddF_y; |
} |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x + ry2; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
F = round (ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2); |
while(y > 0) |
{ |
if(F <= 0) |
{ |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x; |
} |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F += rx2 - ddF_y; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
lcd_ellipse (x0, y0, radius + 3, radius, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
lcd_ellipse_line(x, y, r + 3, r, deg, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_view_font (uint8_t page) |
{ |
int x; |
int y; |
lcd_cls (); |
lcd_printp (PSTR(" 0123456789ABCDEF\r\n"), 0); |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Exit"), 0); |
lcd_ypos = 2; |
for (y = page * 4 ; y < (page * 4 + 4); y++) |
{ |
if (y < 10) |
{ |
lcd_putc (0, lcd_ypos, '0' + y, 0); |
} |
else |
{ |
lcd_putc (0, lcd_ypos, 'A' + y - 10, 0); |
} |
lcd_xpos = 2; |
for (x = 0; x < 16; x++) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, y * 16 + x, 0); |
lcd_xpos++; |
} |
lcd_ypos++; |
} |
} |
//----------------------------------------------------------- |
uint8_t hdigit (uint8_t d) |
{ |
if (d < 10) |
{ |
return '0' + d; |
} |
else |
{ |
return 'A' + d - 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos, lcd_ypos, hdigit (h & 0x0f), mode); |
} |
//----------------------------------------------------------- |
void lcd_print_hex (uint8_t h, uint8_t mode) |
{ |
// lcd_xpos = x; |
// lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h & 0x0f), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, ' ', mode); |
} |
//----------------------------------------------------------- |
void lcd_write_number_u (uint8_t number) |
{ |
uint8_t num = 100; |
uint8_t started = 0; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) |
{ |
lcd_putc (lcd_xpos++, lcd_ypos, '0' + b, 0); |
started = 1; |
} |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_write_number_u (number); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
utoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad==1) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', mode); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', mode); |
lcd_putc (x, y, '0', mode); |
} |
else |
{ |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', mode); |
lcd_putc (x++, y, rest, mode); |
} |
//----------------------------------------------------------- |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
uint8_t num = 100; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if ((num / 10) == 1) |
{ |
lcd_putc (x++, y, '.', 0); |
} |
lcd_putc (x++, y, '0' + b, 0); |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode) |
{ |
char s[7]; |
itoa (number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', mode); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', mode); |
} |
else |
{ |
lcd_putc (x++, y, ' ', mode); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', mode); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', mode); |
lcd_putc (x, y, '0', mode); |
} |
else |
{ |
lcd_print_at(x, y, (uint8_t*)s, mode); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', mode); |
lcd_putc (x++, y, rest, mode); |
} |
//----------------------------------------------------------- |
// write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
// |
void write_time (uint8_t x, uint8_t y, uint16_t seconds) |
{ |
uint16_t min = seconds / 60; |
seconds -= min * 60; |
write_ndigit_number_u (x, y, min, 2, 0,0); |
lcd_putc (x + 2, y, ':', 0); |
write_ndigit_number_u (x + 3, y, seconds, 2, 1,0); |
} |
//----------------------------------------------------------- |
// wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
// |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position) |
{ |
if (position < 0) |
{ |
position ^= ~0; |
position++; |
lcd_putc (x++, y, '-', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
write_ndigit_number_u (x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1,0); |
lcd_putc (x + 3, y, '.', 0); |
position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000); |
write_ndigit_number_u (x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1,0); |
position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000); |
write_ndigit_number_u (x + 8, y, (uint16_t) position, 3, 1,0); |
lcd_putc (x + 11, y, 0x1e, 0); // degree symbol |
} |
//------------------------------------------------------------------------------------ |
// Show PKT Baudrate at given position |
// |
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode) |
{ |
switch (Baudrate) |
{ |
case Baud_2400: lcd_printp_at (x, y, PSTR("2400"), mode);break; |
case Baud_4800: lcd_printp_at (x, y, PSTR("4800"), mode);break; |
case Baud_9600: lcd_printp_at (x, y, PSTR("9600"), mode);break; |
case Baud_19200: lcd_printp_at (x, y, PSTR("19200"), mode);break; |
case Baud_38400: lcd_printp_at (x, y, PSTR("38400"), mode);break; |
case Baud_57600: lcd_printp_at (x, y, PSTR("57600"), mode);break; |
case Baud_115200: lcd_printp_at (x, y, PSTR("115200"), mode);break; |
break; |
} |
} |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd.h |
---|
0,0 → 1,303 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* Thanks to Oliver Schwaneberg for adding several functions to this library!* |
* * |
* Author: Jan Michel (jan at mueschelsoft dot de) * |
* License: GNU General Public License, version 3 * |
* Version: v0.93 September 2010 * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _LCD_H |
#define _LCD_H |
#define MNORMAL 0 // |
#define MINVERS 2 |
#define MBIG 3 |
#define MBIGINVERS 4 |
//------------------------------------------------------------------------------------ |
// X-tended |
void lcdx_putc( uint8_t x, uint8_t y, uint8_t c, uint8_t mode, int8_t xoffs, int8_t yoffs ); |
void lcdx_print (uint8_t *text, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void lcdx_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void lcdx_printp (const char *text, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void lcdx_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void writex_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void writex_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void writex_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void writex_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void writex_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, int8_t xoffs, int8_t yoffs); |
void lcdx_puts_at(uint8_t x, uint8_t y, const char *s, uint8_t mode, int8_t xoffs, int8_t yoffs); |
void writex_time (uint8_t x, uint8_t y, uint16_t seconds, uint8_t mode, int8_t xoffs, int8_t yoffs); |
/* |
//----------------------------------------------------------------------------- |
// Command Codes |
//----------------------------------------------------------------------------- |
//1: Display on/off |
#define LCD_DISPLAY_ON 0xAF //switch display on |
#define LCD_DISPLAY_OFF 0xAE //switch display off |
//2: display start line set (lower 6 bits select first line on lcd from 64 lines in memory) |
#define LCD_START_LINE 0x40 |
//3: Page address set (lower 4 bits select one of 8 pages) |
#define LCD_PAGE_ADDRESS 0xB0 |
//4: column address (lower 4 bits are upper / lower nibble of column address) |
#define LCD_COL_ADDRESS_MSB 0x10 |
#define LCD_COL_ADDRESS_LSB 0x00 //second part of column address |
//8: select orientation (black side of the display should be further away from viewer) |
#define LCD_BOTTOMVIEW 0xA1 //6 o'clock view |
#define LCD_TOPVIEW 0xA0 //12 o'clock view |
//9: select normal (white background, black pixels) or reverse (black background, white pixels) mode |
#define LCD_DISPLAY_POSITIVE 0xA6 //not inverted mode |
#define LCD_DISPLAY_INVERTED 0xA7 //inverted display |
//10: show memory content or switch all pixels on |
#define LCD_SHOW_NORMAL 0xA4 //show dram content |
#define LCD_SHOW_ALL_POINTS 0xA5 //show all points |
//11: lcd bias set |
#define LCD_BIAS_1_9 0xA2 |
#define LCD_BIAS_1_7 0xA3 |
//14: Reset Controller |
#define LCD_RESET_CMD 0xE2 |
//15: output mode select (turns display upside-down) |
#define LCD_SCAN_DIR_NORMAL 0xC0 //normal scan direction |
#define LCD_SCAN_DIR_REVERSE 0xC8 //reversed scan direction |
//16: power control set (lower 3 bits select operating mode) |
//Bit 0: Voltage follower on/off - Bit 1: Voltage regulator on/off - Bit 2: Booster circuit on/off |
#define LCD_POWER_CONTROL 0x28 //base command |
#define LCD_POWER_LOW_POWER 0x2F |
#define LCD_POWER_WIDE_RANGE 0x2F |
#define LCD_POWER_LOW_VOLTAGE 0x2B |
//17: voltage regulator resistor ratio set (lower 3 bits select ratio) |
//selects lcd voltage - 000 is low (~ -2V), 111 is high (~ - 10V), also depending on volume mode. Datasheet suggests 011 |
#define LCD_VOLTAGE 0x20 |
//18: Volume mode set (2-byte command, lower 6 bits in second word select value, datasheet suggests 0x1F) |
#define LCD_VOLUME_MODE_1 0x81 |
#define LCD_VOLUME_MODE_2 0x00 |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
//19: static indicator (2-byte command), first on/off, then blinking mode |
#define LCD_INDICATOR_ON 0xAD //static indicator on |
#define LCD_INDICATOR_OFF 0xAC //static indicator off |
#define LCD_INDICATOR_MODE_OFF 0x00 |
#define LCD_INDICATOR_MODE_1HZ 0x01 |
#define LCD_INDICATOR_MODE_2HZ 0x10 |
#define LCD_INDICATOR_MODE_ON 0x11 |
//20: booster ratio set (2-byte command) |
#define LCD_BOOSTER_SET 0xF8 //set booster ratio |
#define LCD_BOOSTER_234 0x00 //2x-4x |
#define LCD_BOOSTER_5 0x01 //5x |
#define LCD_BOOSTER_6 0x03 //6x |
//#endif |
//22: NOP command |
#define LCD_NOP 0xE3 |
//#if DISPLAY_TYPE == 102 |
////25: advanced program control |
//#define LCD_ADV_PROG_CTRL 0xFA |
//#define LCD_ADV_PROG_CTRL2 0x10 |
//#endif |
//----------------------------------------------------------------------------- |
// Makros to execute commands |
//----------------------------------------------------------------------------- |
#define LCD_SWITCH_ON() lcd_command(LCD_DISPLAY_ON) |
#define LCD_SWITCH_OFF() lcd_command(LCD_DISPLAY_OFF) |
#define LCD_SET_FIRST_LINE(i) lcd_command(LCD_START_LINE | ((i) & 0x3F)) |
#define LCD_SET_PAGE_ADDR(i) lcd_command(LCD_PAGE_ADDRESS | ((i) & 0x0F)) |
#define LCD_SET_COLUMN_ADDR(i) lcd_command(LCD_COL_ADDRESS_MSB | ((i>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((i) & 0x0F)) |
#define LCD_GOTO_ADDRESS(page,col); lcd_command(LCD_PAGE_ADDRESS | ((page) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_MSB | ((col>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((col) & 0x0F)); |
#define LCD_SET_BOTTOM_VIEW() lcd_command(LCD_BOTTOMVIEW) |
#define LCD_SET_TOP_VIEW() lcd_command(LCD_TOPVIEW) |
#define LCD_SET_MODE_POSITIVE() lcd_command(LCD_DISPLAY_POSITIVE) |
#define LCD_SET_MODE_INVERTED() lcd_command(LCD_DISPLAY_INVERTED) |
#define LCD_SHOW_ALL_PIXELS_ON() lcd_command(LCD_SHOW_ALL_POINTS) |
#define LCD_SHOW_ALL_PIXELS_OFF() lcd_command(LCD_SHOW_NORMAL) |
#define LCD_SET_BIAS_RATIO_1_7() lcd_command(LCD_BIAS_1_7) |
#define LCD_SET_BIAS_RATIO_1_9() lcd_command(LCD_BIAS_1_9) |
#define LCD_SEND_RESET() lcd_command(LCD_RESET_CMD) |
#define LCD_ORIENTATION_NORMAL() lcd_command(LCD_SCAN_DIR_NORMAL) |
#define LCD_ORIENTATION_UPSIDEDOWN() lcd_command(LCD_SCAN_DIR_REVERSE) |
#define LCD_SET_POWER_CONTROL(i) lcd_command(LCD_POWER_CONTROL | ((i) & 0x07)) |
#define LCD_SET_LOW_POWER() lcd_command(LCD_POWER_LOW_POWER) |
#define LCD_SET_WIDE_RANGE() lcd_command(LCD_POWER_WIDE_RANGE) |
#define LCD_SET_LOW_VOLTAGE() lcd_command(LCD_POWER_LOW_VOLTAGE) |
#define LCD_SET_BIAS_VOLTAGE(i) lcd_command(LCD_VOLTAGE | ((i) & 0x07)) |
#define LCD_SET_VOLUME_MODE(i) lcd_command(LCD_VOLUME_MODE_1); \ |
lcd_command(LCD_VOLUME_MODE_2 | ((i) & 0x3F)) |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
#define LCD_SET_INDICATOR_OFF() lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_INDICATOR_MODE_OFF) |
#define LCD_SET_INDICATOR_STATIC() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_ON) |
#define LCD_SET_INDICATOR_1HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_1HZ) |
#define LCD_SET_INDICATOR_2HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_2HZ) |
#define LCD_SET_INDICATOR(i,j) lcd_command(LCD_INDICATOR_OFF | ((i) & 1)); \ |
lcd_command(((j) & 2)) |
#define LCD_SLEEP_MODE lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_DISPLAY_OFF); \ |
lcd_command(LCD_SHOW_ALL_POINTS) |
//#endif |
//#if DISPLAY_TYPE == 102 |
//#define LCD_TEMPCOMP_HIGH 0x80 |
//#define LCD_COLWRAP 0x02 |
//#define LCD_PAGEWRAP 0x01 |
//#define LCD_SET_ADV_PROG_CTRL(i) lcd_command(LCD_ADV_PROG_CTRL); |
// lcd_command(LCD_ADV_PROG_CTRL2 & i) |
//#endif |
*/ |
extern volatile uint8_t LCD_ORIENTATION; |
//#define LCD_LINES 8 |
//#define LCD_COLS 21 |
extern uint8_t lcd_xpos; |
extern uint8_t lcd_ypos; |
void lcd_command(uint8_t cmd); |
void send_byte (uint8_t data); |
void LCD_Init (uint8_t LCD_Mode); |
void new_line (void); |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ); |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void send_byte (uint8_t data); |
void lcd_print (uint8_t *text, uint8_t mode); |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode); |
void lcd_printp (const char *text, uint8_t mode); |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_printpns (const char *text, uint8_t mode); |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_cls (void); |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w); |
void print_display (uint8_t *text); |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text); |
void copy_line (uint8_t y); |
void paste_line (uint8_t y); |
void lcd_plot (uint8_t x, uint8_t y, uint8_t mode); |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode); |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode); |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode); |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_view_font (uint8_t page); |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode); |
void lcd_write_number_u (uint8_t number); |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number); |
void lcd_print_hex (uint8_t h, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad,uint8_t mode); |
/** |
* Write only some digits of a signed <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /100th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* write <seconds> as human readable time at <x>/<y> |
*/ |
void write_time (uint8_t x, uint8_t y, uint16_t seconds); |
/** |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position); |
//------------------------------------------------------------------------------------ |
// Show PKT Baudrate at given position |
// |
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd.hold |
---|
0,0 → 1,282 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* Thanks to Oliver Schwaneberg for adding several functions to this library!* |
* * |
* Author: Jan Michel (jan at mueschelsoft dot de) * |
* License: GNU General Public License, version 3 * |
* Version: v0.93 September 2010 * |
* * |
* 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. * |
* * |
* 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _LCD_H |
#define _LCD_H |
/* |
//----------------------------------------------------------------------------- |
// Command Codes |
//----------------------------------------------------------------------------- |
//1: Display on/off |
#define LCD_DISPLAY_ON 0xAF //switch display on |
#define LCD_DISPLAY_OFF 0xAE //switch display off |
//2: display start line set (lower 6 bits select first line on lcd from 64 lines in memory) |
#define LCD_START_LINE 0x40 |
//3: Page address set (lower 4 bits select one of 8 pages) |
#define LCD_PAGE_ADDRESS 0xB0 |
//4: column address (lower 4 bits are upper / lower nibble of column address) |
#define LCD_COL_ADDRESS_MSB 0x10 |
#define LCD_COL_ADDRESS_LSB 0x00 //second part of column address |
//8: select orientation (black side of the display should be further away from viewer) |
#define LCD_BOTTOMVIEW 0xA1 //6 o'clock view |
#define LCD_TOPVIEW 0xA0 //12 o'clock view |
//9: select normal (white background, black pixels) or reverse (black background, white pixels) mode |
#define LCD_DISPLAY_POSITIVE 0xA6 //not inverted mode |
#define LCD_DISPLAY_INVERTED 0xA7 //inverted display |
//10: show memory content or switch all pixels on |
#define LCD_SHOW_NORMAL 0xA4 //show dram content |
#define LCD_SHOW_ALL_POINTS 0xA5 //show all points |
//11: lcd bias set |
#define LCD_BIAS_1_9 0xA2 |
#define LCD_BIAS_1_7 0xA3 |
//14: Reset Controller |
#define LCD_RESET_CMD 0xE2 |
//15: output mode select (turns display upside-down) |
#define LCD_SCAN_DIR_NORMAL 0xC0 //normal scan direction |
#define LCD_SCAN_DIR_REVERSE 0xC8 //reversed scan direction |
//16: power control set (lower 3 bits select operating mode) |
//Bit 0: Voltage follower on/off - Bit 1: Voltage regulator on/off - Bit 2: Booster circuit on/off |
#define LCD_POWER_CONTROL 0x28 //base command |
#define LCD_POWER_LOW_POWER 0x2F |
#define LCD_POWER_WIDE_RANGE 0x2F |
#define LCD_POWER_LOW_VOLTAGE 0x2B |
//17: voltage regulator resistor ratio set (lower 3 bits select ratio) |
//selects lcd voltage - 000 is low (~ -2V), 111 is high (~ - 10V), also depending on volume mode. Datasheet suggests 011 |
#define LCD_VOLTAGE 0x20 |
//18: Volume mode set (2-byte command, lower 6 bits in second word select value, datasheet suggests 0x1F) |
#define LCD_VOLUME_MODE_1 0x81 |
#define LCD_VOLUME_MODE_2 0x00 |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
//19: static indicator (2-byte command), first on/off, then blinking mode |
#define LCD_INDICATOR_ON 0xAD //static indicator on |
#define LCD_INDICATOR_OFF 0xAC //static indicator off |
#define LCD_INDICATOR_MODE_OFF 0x00 |
#define LCD_INDICATOR_MODE_1HZ 0x01 |
#define LCD_INDICATOR_MODE_2HZ 0x10 |
#define LCD_INDICATOR_MODE_ON 0x11 |
//20: booster ratio set (2-byte command) |
#define LCD_BOOSTER_SET 0xF8 //set booster ratio |
#define LCD_BOOSTER_234 0x00 //2x-4x |
#define LCD_BOOSTER_5 0x01 //5x |
#define LCD_BOOSTER_6 0x03 //6x |
//#endif |
//22: NOP command |
#define LCD_NOP 0xE3 |
//#if DISPLAY_TYPE == 102 |
////25: advanced program control |
//#define LCD_ADV_PROG_CTRL 0xFA |
//#define LCD_ADV_PROG_CTRL2 0x10 |
//#endif |
//----------------------------------------------------------------------------- |
// Makros to execute commands |
//----------------------------------------------------------------------------- |
#define LCD_SWITCH_ON() lcd_command(LCD_DISPLAY_ON) |
#define LCD_SWITCH_OFF() lcd_command(LCD_DISPLAY_OFF) |
#define LCD_SET_FIRST_LINE(i) lcd_command(LCD_START_LINE | ((i) & 0x3F)) |
#define LCD_SET_PAGE_ADDR(i) lcd_command(LCD_PAGE_ADDRESS | ((i) & 0x0F)) |
#define LCD_SET_COLUMN_ADDR(i) lcd_command(LCD_COL_ADDRESS_MSB | ((i>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((i) & 0x0F)) |
#define LCD_GOTO_ADDRESS(page,col); lcd_command(LCD_PAGE_ADDRESS | ((page) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_MSB | ((col>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((col) & 0x0F)); |
#define LCD_SET_BOTTOM_VIEW() lcd_command(LCD_BOTTOMVIEW) |
#define LCD_SET_TOP_VIEW() lcd_command(LCD_TOPVIEW) |
#define LCD_SET_MODE_POSITIVE() lcd_command(LCD_DISPLAY_POSITIVE) |
#define LCD_SET_MODE_INVERTED() lcd_command(LCD_DISPLAY_INVERTED) |
#define LCD_SHOW_ALL_PIXELS_ON() lcd_command(LCD_SHOW_ALL_POINTS) |
#define LCD_SHOW_ALL_PIXELS_OFF() lcd_command(LCD_SHOW_NORMAL) |
#define LCD_SET_BIAS_RATIO_1_7() lcd_command(LCD_BIAS_1_7) |
#define LCD_SET_BIAS_RATIO_1_9() lcd_command(LCD_BIAS_1_9) |
#define LCD_SEND_RESET() lcd_command(LCD_RESET_CMD) |
#define LCD_ORIENTATION_NORMAL() lcd_command(LCD_SCAN_DIR_NORMAL) |
#define LCD_ORIENTATION_UPSIDEDOWN() lcd_command(LCD_SCAN_DIR_REVERSE) |
#define LCD_SET_POWER_CONTROL(i) lcd_command(LCD_POWER_CONTROL | ((i) & 0x07)) |
#define LCD_SET_LOW_POWER() lcd_command(LCD_POWER_LOW_POWER) |
#define LCD_SET_WIDE_RANGE() lcd_command(LCD_POWER_WIDE_RANGE) |
#define LCD_SET_LOW_VOLTAGE() lcd_command(LCD_POWER_LOW_VOLTAGE) |
#define LCD_SET_BIAS_VOLTAGE(i) lcd_command(LCD_VOLTAGE | ((i) & 0x07)) |
#define LCD_SET_VOLUME_MODE(i) lcd_command(LCD_VOLUME_MODE_1); \ |
lcd_command(LCD_VOLUME_MODE_2 | ((i) & 0x3F)) |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
#define LCD_SET_INDICATOR_OFF() lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_INDICATOR_MODE_OFF) |
#define LCD_SET_INDICATOR_STATIC() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_ON) |
#define LCD_SET_INDICATOR_1HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_1HZ) |
#define LCD_SET_INDICATOR_2HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_2HZ) |
#define LCD_SET_INDICATOR(i,j) lcd_command(LCD_INDICATOR_OFF | ((i) & 1)); \ |
lcd_command(((j) & 2)) |
#define LCD_SLEEP_MODE lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_DISPLAY_OFF); \ |
lcd_command(LCD_SHOW_ALL_POINTS) |
//#endif |
//#if DISPLAY_TYPE == 102 |
//#define LCD_TEMPCOMP_HIGH 0x80 |
//#define LCD_COLWRAP 0x02 |
//#define LCD_PAGEWRAP 0x01 |
//#define LCD_SET_ADV_PROG_CTRL(i) lcd_command(LCD_ADV_PROG_CTRL); |
// lcd_command(LCD_ADV_PROG_CTRL2 & i) |
//#endif |
*/ |
extern volatile uint8_t LCD_ORIENTATION; |
//#define LCD_LINES 8 |
//#define LCD_COLS 21 |
extern uint8_t lcd_xpos; |
extern uint8_t lcd_ypos; |
void lcd_command(uint8_t cmd); |
void send_byte (uint8_t data); |
void LCD_Init (uint8_t LCD_Mode); |
void new_line (void); |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ); |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void send_byte (uint8_t data); |
void lcd_print (uint8_t *text, uint8_t mode); |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode); |
void lcd_printp (const char *text, uint8_t mode); |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_printpns (const char *text, uint8_t mode); |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_cls (void); |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w); |
void print_display (uint8_t *text); |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text); |
void copy_line (uint8_t y); |
void paste_line (uint8_t y); |
// Jeti |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void lcd_printpj (const char *text, uint8_t mode); |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_plot (uint8_t x, uint8_t y, uint8_t mode); |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode); |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode); |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode); |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_view_font (uint8_t page); |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode); |
void lcd_write_number_u (uint8_t number); |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number); |
void lcd_print_hex (uint8_t h, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad,uint8_t mode); |
/** |
* Write only some digits of a signed <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /100th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
/** |
* write <seconds> as human readable time at <x>/<y> |
*/ |
void write_time (uint8_t x, uint8_t y, uint16_t seconds); |
/** |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position); |
//------------------------------------------------------------------------------------ |
// Show PKT Baudrate at given position |
// |
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode); |
#endif |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/lcd/lcd.zip |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |