paul@156 | 1 | /* |
paul@156 | 2 | * Example tasks. |
paul@156 | 3 | * |
paul@156 | 4 | * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> |
paul@156 | 5 | * |
paul@156 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@156 | 7 | * it under the terms of the GNU General Public License as published by |
paul@156 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@156 | 9 | * (at your option) any later version. |
paul@156 | 10 | * |
paul@156 | 11 | * This program is distributed in the hope that it will be useful, |
paul@156 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@156 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@156 | 14 | * GNU General Public License for more details. |
paul@156 | 15 | * |
paul@156 | 16 | * You should have received a copy of the GNU General Public License |
paul@156 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@156 | 18 | */ |
paul@156 | 19 | |
paul@156 | 20 | #include "board.h" |
paul@156 | 21 | #include "lcd.h" |
paul@156 | 22 | #include "jzlcd.h" |
paul@156 | 23 | #include "tasks.h" |
paul@156 | 24 | |
paul@156 | 25 | extern vidinfo_t panel_info; |
paul@156 | 26 | |
paul@156 | 27 | void next_pixel(unsigned short *x, unsigned short *y) |
paul@156 | 28 | { |
paul@156 | 29 | (*x)++; |
paul@156 | 30 | if (*x >= panel_info.vl_col) { |
paul@156 | 31 | *x = 0; |
paul@156 | 32 | (*y)++; |
paul@156 | 33 | if (*y >= panel_info.vl_row) |
paul@156 | 34 | *y = 0; |
paul@156 | 35 | } |
paul@156 | 36 | } |
paul@156 | 37 | |
paul@162 | 38 | void plot_value(u32 value) |
paul@162 | 39 | { |
paul@168 | 40 | unsigned short x, y; |
paul@164 | 41 | |
paul@164 | 42 | while (1) |
paul@162 | 43 | { |
paul@164 | 44 | for (y = 0; y < panel_info.vl_row; y++) |
paul@162 | 45 | { |
paul@164 | 46 | for (x = 0; x < panel_info.vl_col; x++) |
paul@164 | 47 | { |
paul@168 | 48 | set_pixel(x, y, get_bitmap_value(x, value)); |
paul@164 | 49 | } |
paul@162 | 50 | } |
paul@162 | 51 | } |
paul@162 | 52 | } |
paul@162 | 53 | |
paul@156 | 54 | /* Tasks. */ |
paul@156 | 55 | |
paul@156 | 56 | void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y) |
paul@156 | 57 | { |
paul@156 | 58 | while (1) { |
paul@162 | 59 | test_pixel(x, y, pixel_type); |
paul@156 | 60 | next_pixel(&x, &y); |
paul@156 | 61 | udelay(100); |
paul@156 | 62 | } |
paul@156 | 63 | } |
paul@156 | 64 | |
paul@156 | 65 | void start_plot_pattern(unsigned short task) |
paul@156 | 66 | { |
paul@164 | 67 | u32 args[] = {task, 0, (task * (panel_info.vl_row / 4)) % panel_info.vl_row}; |
paul@156 | 68 | |
paul@156 | 69 | start_task(task, (void (*)()) plot_pattern, args, 3); |
paul@156 | 70 | } |