/* * Copyright (C) OpenTX * * Based on code named * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * 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. */ void lcdSendCtl(uint8_t val) { PORTC_LCD_CTRL &= ~(1< 31) { y_addr = y - 32; //Because there are only 31 addressable lines in the ST7920 x_addr += 8; //so we overflow x (7 visible bytes per line) to reach the bottom half } else { y_addr = y; } lcdSendCtl( 0x80 | y_addr ); //Set Vertical Address _delay_us(49); lcdSendCtl( 0x80 | x_addr ); //Set Horizontal Address _delay_us(49); PORTC_LCD_CTRL |= (1< 0=0, 1=1..7=7, 8=0, 9=1... col_offset = 1 << bit_count; //Build a value for a AND operation with the vorrect bitposition line_offset = ( y / 8 ) * 128; //On the ST7565 there are 8 lines with each 128 bytes width for (coord_t x=0; x<16; x++) { //Walk through 16 bytes form left to right (128 Pixel) p = displayBuf + line_offset + ( x * 8 ); //Calculate the position of the first byte im array // adressing the bytes sequential and set the bits at the correct position merging them with an OR operation to get all bits in one byte // the position of the LSB is the right-most position of the byte to the ST7920 result = ((*p++ & col_offset)!=0?0x80:0); result |= ((*p++ & col_offset)!=0?0x40:0); result |= ((*p++ & col_offset)!=0?0x20:0); result |= ((*p++ & col_offset)!=0?0x10:0); result |= ((*p++ & col_offset)!=0?0x08:0); result |= ((*p++ & col_offset)!=0?0x04:0); result |= ((*p++ & col_offset) !=0?0x02:0); result |= ((*p++ & col_offset)!=0?0x01:0); PORTA_LCD_DAT = result; PORTC_LCD_CTRL |= (1<