CommonPIC32

lib/display.c

41:8b24f43ed2e6
2018-10-23 Paul Boddie Added support for a framebuffer, also providing a common library function to initialise the framebuffer with a test pattern.
     1 /*     2  * Common display-related functions.     3  *     4  * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>     5  *     6  * This program is free software: you can redistribute it and/or modify     7  * it under the terms of the GNU General Public License as published by     8  * the Free Software Foundation, either version 3 of the License, or     9  * (at your option) any later version.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.    18  */    19     20 #include "display.h"    21     22 /* Provided by the application. */    23     24 #include "vga.h"    25     26     27     28 /* Provide a pattern to test the line data. */    29     30 void test_linedata(uint8_t *framebuffer)    31 {    32     int x, y;    33     uint8_t *linedata = framebuffer;    34     35     for (y = 0; y < LINE_COUNT; y++)    36     {    37         for (x = 0; x < LINE_LENGTH; x++)    38         {    39             /* Pixel: I0RRGGBB = Y0YYYYXX */    40     41             linedata[x] = (x % 2) ?    42                             (((y / (LINE_COUNT / 32)) & 0b1) << 7) |    43                             (((y / (LINE_COUNT / 16)) & 0b1111) << 2) |    44                             ((x / (LINE_LENGTH / 4)) & 0b11) :    45                           0x00;    46         }    47     48         linedata += LINE_LENGTH;    49     }    50 }