C-Berry: Linien zeichnen
Recktecke und Kreise sind zwar schon recht hübsch, aber Linien braucht man auch noch ;-).
Benutzung:
tft_line start_x start_y ende_x ende_y farbe
Hier der Quellcode:
#include <bcm2835.h> #include "tft.h" #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include "RAIO8870.h" int main (int argc, char *argv[]){ if(!bcm2835_init()){ printf("tft_line: Error, display can not be initialized!"); exit(1); } if( argc < 6 ){ printf("tft_line: Error, not enough arguments! Required: x1 y1 x2 y2 color\n"); exit(1); } if( argc > 6 ){ printf("tft_line: Error, too many arguments! Required: x1 y1 x2 y2 color\n"); exit(2); } int x1=atoi(argv[1]); int y1=atoi(argv[2]); int x2=atoi(argv[3]); int y2=atoi(argv[4]); int color=atoi(argv[5]); if ( x1 < 0 || x1 > 319 ){ printf("tft_line: Error, x1 out of range! x1: 0...319!\n"); exit(4); } if (y1 < 0 || y1 > 239){ printf("tft_line: Error, y1 out of range! y1: 0...239!\n"); exit(4); } if (x2 < 0 || x2 > 319){ printf("tft_line: Error, x2 out of range! x2: 0...319!\n"); exit(4); } if (y2 < 0 || y2 > 239){ printf("tft_line: Error, y2 out of range! y2: 0...239!\n"); exit(4); } if( color < 0 || color > 255){ printf("tft_line: Error, color out of range! color: 0...255!\n"); exit (4); } Draw_Line ( x1, y1, x2, y2 ); Text_Foreground_Color ( color ); RAIO_StartDrawing ( LINE ); return 0; }
Und für alle, die zu faul zum Abtippen sind, hier das File zum Download: tft_line.c