Разное о выращивании табака на Алтае
Вы не вошли.
Страницы 1
Рисуем квадратичную функцию на VGA32.
#include "fabgl.h"
#include "Arduino.h"
fabgl::VGAController DisplayController;
fabgl::Canvas canvas(&DisplayController);
int x=0;
int y=0;
//////////////////////////////////////
// Начало функции обработки кириллических символов
#define maxString 40
char target[maxString + 1] = "";
char *ru(char *source)
{ int i,j,k;
unsigned char n;
char m[2] = { '0', '\0' };
strcpy(target, ""); k = strlen(source); i = j = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xC0) {
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; break; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x30;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB8; break; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x70;
break;
}
}
}
m[0] = n; strcat(target, m);
j++; if (j >= maxString) break;
}
return target;
}
// Конец функции обработки кириллических символов.
void setup()
{
Serial.begin(115200);
DisplayController.begin();
DisplayController.setResolution(VGA_320x200_75Hz);
canvas.setBrushColor(RGB888(0, 0, 0));
canvas.setGlyphOptions(GlyphOptions().FillBackground(true).DoubleWidth(0));
canvas.setPenColor(Color::BrightGreen);
canvas.clear();
canvas.selectFont(&fabgl::FONT_8x8);
canvas.drawTextFmt(2,2,"%s",ru("График квадратичной функции."));
canvas.drawTextFmt(2,15,"%s","Graph of a quadratic function.");
}
void loop()
{
canvas.setPenColor(Color::BrightBlue);
canvas.drawLine(100,30,100,200);//ОСЬ X
canvas.drawLine(0,170,300,170);//ОСЬ Y
canvas.setPenColor(Color::BrightGreen);
for (int x = 0; x < 320; x++) {
canvas.setPixel(100+x,170-x*x/10,RGB888(255,0,0));
canvas.setPixel(100-x,170-x*x/10,RGB888(255,0,0));
}
}
Не в сети
Не в сети
#include "fabgl.h"
#include "Arduino.h"
fabgl::VGAController DisplayController;
fabgl::Canvas canvas(&DisplayController);
int x=0;
int y=0;
//////////////////////////////////////
// Начало функции обработки кириллических символов
#define maxString 40
char target[maxString + 1] = "";
char *ru(char *source)
{ int i,j,k;
unsigned char n;
char m[2] = { '0', '\0' };
strcpy(target, ""); k = strlen(source); i = j = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xC0) {
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; break; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x30;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB8; break; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x70;
break;
}
}
}
m[0] = n; strcat(target, m);
j++; if (j >= maxString) break;
}
return target;
}
// Конец функции обработки кириллических символов.
void setup()
{
Serial.begin(115200);
DisplayController.begin();
DisplayController.setResolution(VGA_320x200_75Hz);
canvas.setBrushColor(RGB888(0, 0, 0));
canvas.setGlyphOptions(GlyphOptions().FillBackground(true).DoubleWidth(0));
canvas.setPenColor(Color::BrightGreen);
canvas.clear();
canvas.selectFont(&fabgl::FONT_8x8);
canvas.drawTextFmt(2,2,"%s",ru("График квадратичной функции."));
canvas.drawTextFmt(2,15,"%s","Graph of a quadratic function.");
}
void loop()
{
canvas.setPenColor(Color::BrightBlue);
canvas.drawLine(100,30,100,200);//ОСЬ X
canvas.drawLine(0,170,300,170);//ОСЬ Y
canvas.setPenColor(Color::BrightGreen);
for (int y = 0;y < 15200; y++) {
x=round(sqrt(y));
canvas.setPixel(100+x,170-x*x/100,RGB888(255,0,0));
canvas.setPixel(100-x,170-x*x/100,RGB888(255,0,0));
}
}
Не в сети
Не в сети
#include "fabgl.h"
#include "Arduino.h"
fabgl::VGAController DisplayController;
fabgl::Canvas canvas(&DisplayController);
int x=0;
int y=0;
//////////////////////////////////////
// Начало функции обработки кириллических символов
#define maxString 40
char target[maxString + 1] = "";
char *ru(char *source)
{ int i,j,k;
unsigned char n;
char m[2] = { '0', '\0' };
strcpy(target, ""); k = strlen(source); i = j = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xC0) {
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; break; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x30;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB8; break; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x70;
break;
}
}
}
m[0] = n; strcat(target, m);
j++; if (j >= maxString) break;
}
return target;
}
// Конец функции обработки кириллических символов.
void setup()
{
Serial.begin(115200);
DisplayController.begin();
DisplayController.setResolution(VGA_320x200_75Hz);
canvas.setBrushColor(RGB888(0, 0, 0));
canvas.setGlyphOptions(GlyphOptions().FillBackground(true).DoubleWidth(0));
canvas.setPenColor(Color::BrightGreen);
canvas.clear();
canvas.selectFont(&fabgl::FONT_8x8);
canvas.drawTextFmt(2,2,"%s",ru("График квадратичной функции."));
canvas.drawTextFmt(2,15,"%s","Graph of a quadratic function.");
}
void loop()
{
canvas.setPenColor(Color::BrightBlue);
canvas.drawLine(100,30,100,200);//ОСЬ X
canvas.drawLine(0,70,300,70);//ОСЬ Y
canvas.setPenColor(Color::BrightGreen);
for (int y = 0;y < 15200; y++) {
x=round(sqrt(y));
canvas.setPixel(100+x,70+x*x/100,RGB888(255,0,0));
canvas.setPixel(100-x,70+x*x/100,RGB888(255,0,0));
}
}
Не в сети
Не в сети
Пример Спрайты с сенсорной кнопкой на контакте D27.
#include "fabgl.h"
#include <math.h>
fabgl::VGA8Controller DisplayController;//Запускаем графическую библиотеку с разрешение 8 цветов.
fabgl::Canvas canvas(&DisplayController);
// Mask, 1 bit per pixel. One byte contains 8 pixels. 0 = transparent, 1 = foreground color (in this case it is "RGB888(255, 0, 0)".
const uint8_t bitmap1_data[] = {
0x07, 0xe0, 0x1f, 0xf8, 0x3f, 0xfc, 0x6d, 0xb6, 0xff, 0xff, 0x39, 0x9c, 0x10, 0x08,
};
Bitmap bitmap1 = Bitmap(16, 7, bitmap1_data, PixelFormat::Mask, RGB888(255, 255, 0));
// ABGR, 2 bits per channel. One byte contains one pixel.
const uint8_t bitmap2_data[] = {
0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe9, 0xea, 0xc0, 0x00, 0x00, 0xd4, 0xd4, 0xd4, 0x00, 0x00, 0x00,
0xd5, 0xd5, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0xd4, 0xd5, 0xd9, 0xd9, 0xd9, 0xd5, 0x00,
0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xc0, 0xc0, 0xd4, 0xd5, 0xd9, 0xe9, 0xe9, 0xe9, 0xd9, 0xd5,
0x00, 0xd4, 0xe9, 0xe9, 0xea, 0xea, 0xc0, 0xd4, 0xd5, 0xe9, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0xd5, 0xd5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe9, 0xe9, 0xc0, 0xe9, 0xc0, 0xe9, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xea, 0xea, 0xea, 0xc0, 0xea, 0xc0, 0xea, 0xea, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xd9, 0xd9, 0xd9, 0xc0, 0xd9, 0xc0, 0xd9, 0xd9, 0xd5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd5, 0xd5, 0xc0, 0xd5, 0xc0, 0xd5, 0xd5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0xd5, 0xd5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd4, 0xd9, 0xd9, 0xe9, 0xe9, 0xc0, 0xd4, 0xd5, 0xe9, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00,
0xd5, 0xd5, 0xd5, 0xd5, 0xd5, 0xd5, 0xc0, 0xc0, 0xd4, 0xd5, 0xd9, 0xe9, 0xe9, 0xe9, 0xd9, 0xd5,
0xd4, 0xd4, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0xd4, 0xd5, 0xd9, 0xd9, 0xd5, 0xd5, 0x00,
0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
Bitmap bitmap2 = Bitmap(16, 16, &bitmap2_data[0], PixelFormat::RGBA2222);
// RGBA, 8 bits per channel. Four bytes contains one pixel.
const uint8_t bitmap3_data[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0x9c, 0x9a, 0xba, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xb7, 0xb5, 0xcc, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xdc, 0xdb, 0xe6, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x80, 0x5e, 0x4d, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x3f, 0x2c, 0x16, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Bitmap bitmap3 = Bitmap(16, 15, &bitmap3_data[0], PixelFormat::RGBA8888);
Sprite sprites[3];
void setup()
{
DisplayController.begin();
DisplayController.setResolution(VGA_320x200_75Hz);
// draw background
Canvas cv(&DisplayController);
cv.setBrushColor(RGB888(0, 0, 0));
cv.clear();
cv.setPenColor(RGB888(64, 64, 0));
// associates bitmaps to sprites
sprites[0].addBitmap(&bitmap1);
sprites[1].addBitmap(&bitmap2);
sprites[2].addBitmap(&bitmap3);
// sets initial position
sprites[0].moveTo(0, 50);
sprites[1].moveTo(0, 100);
sprites[2].moveTo(0, 150);
// makes sprites visible
sprites[0].visible = true;
sprites[1].visible = true;
sprites[2].visible = true;
// add sprites to display controller
DisplayController.setSprites(sprites, 3);
}
void loop()
{
static double count = 0;
// set position of sprite 0
sprites[0].x += 1;
if (sprites[0].x >= DisplayController.getViewPortWidth()) sprites[0].x = 0;
sprites[0].y = 10; //+ 35.0 * sin(count);
// set position of sprite 1
sprites[1].x += 1;
if (sprites[1].x >= DisplayController.getViewPortWidth()) sprites[1].x = 0;
sprites[1].y = 50;
if (touchRead(27)>80 ) sprites[1].y = 80;// else sprites[1].y = 50;
// update sprites positions
DisplayController.refreshSprites();
count += 0.10;
delay(std::max(100, 50 - (int)count / 2));
Не в сети
Страницы 1