daily_automated
This commit is contained in:
395
trunk/Arduino/libraries/Ucglib/examples/Box3D/Box3D.ino
Normal file
395
trunk/Arduino/libraries/Ucglib/examples/Box3D/Box3D.ino
Normal file
@@ -0,0 +1,395 @@
|
||||
/*
|
||||
|
||||
Box3D.ino
|
||||
|
||||
Draw a rotating 3D box
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 17, /*cd=*/ 16, /*cs=*/ 0, /*reset=*/ 2); /* FT SSD1351 direct connect to ESP32 */
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
|
||||
// define a 3d point structure
|
||||
struct pt3d
|
||||
{
|
||||
ucg_int_t x, y, z;
|
||||
};
|
||||
|
||||
struct surface
|
||||
{
|
||||
uint8_t p[4];
|
||||
int16_t z;
|
||||
};
|
||||
|
||||
struct pt2d
|
||||
{
|
||||
ucg_int_t x, y;
|
||||
unsigned is_visible;
|
||||
};
|
||||
|
||||
|
||||
// define the point at which the observer looks, 3d box will be centered there
|
||||
#define MX (ucg.getWidth()/2)
|
||||
#define MY (ucg.getHeight()/2)
|
||||
|
||||
// define a value that corresponds to "1"
|
||||
#define U 64
|
||||
|
||||
// eye to screen distance (fixed)
|
||||
#define ZS U
|
||||
|
||||
// cube edge length is 2*U
|
||||
struct pt3d cube[8] =
|
||||
{
|
||||
{ -U, -U, U},
|
||||
{ U, -U, U},
|
||||
{ U, -U, -U},
|
||||
{ -U, -U, -U},
|
||||
{ -U, U, U},
|
||||
{ U, U, U},
|
||||
{ U, U, -U},
|
||||
{ -U, U, -U},
|
||||
};
|
||||
|
||||
// define the surfaces
|
||||
struct surface cube_surface[6] =
|
||||
{
|
||||
{ {0, 1, 2, 3}, 0 }, // bottom
|
||||
{ {4, 5, 6, 7}, 0 }, // top
|
||||
{ {0, 1, 5, 4}, 0 }, // back
|
||||
|
||||
{ {3, 7, 6, 2}, 0 }, // front
|
||||
{ {1, 2, 6, 5}, 0 }, // right
|
||||
{ {0, 3, 7, 4}, 0 }, // left
|
||||
};
|
||||
|
||||
// define some structures for the copy of the box, calculation will be done there
|
||||
struct pt3d cube2[8];
|
||||
struct pt2d cube_pt[8];
|
||||
|
||||
// will contain a rectangle border of the box projection into 2d plane
|
||||
ucg_int_t x_min, x_max;
|
||||
ucg_int_t y_min, y_max;
|
||||
|
||||
int16_t sin_tbl[65] = {
|
||||
0,1606,3196,4756,6270,7723,9102,10394,11585,12665,13623,14449,15137,15679,16069,16305,16384,16305,16069,15679,
|
||||
15137,14449,13623,12665,11585,10394,9102,7723,6270,4756,3196,1606,0,-1605,-3195,-4755,-6269,-7722,-9101,-10393,
|
||||
-11584,-12664,-13622,-14448,-15136,-15678,-16068,-16304,-16383,-16304,-16068,-15678,-15136,-14448,-13622,-12664,-11584,-10393,-9101,-7722,
|
||||
-6269,-4755,-3195,-1605,0};
|
||||
|
||||
int16_t cos_tbl[65] = {
|
||||
16384,16305,16069,15679,15137,14449,13623,12665,11585,10394,9102,7723,6270,4756,3196,1606,0,-1605,-3195,-4755,
|
||||
-6269,-7722,-9101,-10393,-11584,-12664,-13622,-14448,-15136,-15678,-16068,-16304,-16383,-16304,-16068,-15678,-15136,-14448,-13622,-12664,
|
||||
-11584,-10393,-9101,-7722,-6269,-4755,-3195,-1605,0,1606,3196,4756,6270,7723,9102,10394,11585,12665,13623,14449,
|
||||
15137,15679,16069,16305,16384};
|
||||
|
||||
|
||||
void copy_cube(void)
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
cube2[i] = cube[i];
|
||||
}
|
||||
}
|
||||
|
||||
void rotate_cube_y(uint16_t w)
|
||||
{
|
||||
uint8_t i;
|
||||
int16_t x, z;
|
||||
/*
|
||||
x' = x * cos(w) + z * sin(w)
|
||||
z' = - x * sin(w) + z * cos(w)
|
||||
*/
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
x = ((int32_t)cube2[i].x * (int32_t)cos_tbl[w] + (int32_t)cube2[i].z * (int32_t)sin_tbl[w])>>14;
|
||||
z = (- (int32_t)cube2[i].x * (int32_t)sin_tbl[w] + (int32_t)cube2[i].z * (int32_t)cos_tbl[w])>>14;
|
||||
//printf("%d: %d %d --> %d %d\n", i, cube2[i].x, cube2[i].z, x, z);
|
||||
cube2[i].x = x;
|
||||
cube2[i].z = z;
|
||||
}
|
||||
}
|
||||
|
||||
void rotate_cube_x(uint16_t w)
|
||||
{
|
||||
uint8_t i;
|
||||
int16_t y, z;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
y = ((int32_t)cube2[i].y * (int32_t)cos_tbl[w] + (int32_t)cube2[i].z * (int32_t)sin_tbl[w])>>14;
|
||||
z = (- (int32_t)cube2[i].y * (int32_t)sin_tbl[w] + (int32_t)cube2[i].z * (int32_t)cos_tbl[w])>>14;
|
||||
cube2[i].y = y;
|
||||
cube2[i].z = z;
|
||||
}
|
||||
}
|
||||
|
||||
void trans_cube(uint16_t z)
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
cube2[i].z += z;
|
||||
}
|
||||
}
|
||||
|
||||
void reset_min_max(void)
|
||||
{
|
||||
x_min = 0x07fff;
|
||||
y_min = 0x07fff;
|
||||
x_max = -0x07fff;
|
||||
y_max = -0x07fff;
|
||||
}
|
||||
|
||||
// calculate xs and ys from a 3d value
|
||||
void convert_3d_to_2d(struct pt3d *p3, struct pt2d *p2)
|
||||
{
|
||||
int32_t t;
|
||||
p2->is_visible = 1;
|
||||
if ( p3->z >= ZS )
|
||||
{
|
||||
t = ZS;
|
||||
t *= p3->x;
|
||||
t <<=1;
|
||||
t /= p3->z;
|
||||
if ( t >= -MX && t <= MX-1 )
|
||||
{
|
||||
t += MX;
|
||||
p2->x = t;
|
||||
|
||||
if ( x_min > t )
|
||||
x_min = t;
|
||||
if ( x_max < t )
|
||||
x_max = t;
|
||||
|
||||
t = ZS;
|
||||
t *= p3->y;
|
||||
t <<=1;
|
||||
t /= p3->z;
|
||||
if ( t >= -MY && t <= MY-1 )
|
||||
{
|
||||
t += MY;
|
||||
p2->y = t;
|
||||
|
||||
if ( y_min > t )
|
||||
y_min = t;
|
||||
if ( y_max < t )
|
||||
y_max = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
p2->is_visible = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p2->is_visible = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p2->is_visible = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void convert_cube(void)
|
||||
{
|
||||
uint8_t i;
|
||||
reset_min_max();
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
convert_3d_to_2d(cube2+i, cube_pt+i);
|
||||
//printf("%d: %d %d\n", i, cube_pt[i].x, cube_pt[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
void calculate_z(void)
|
||||
{
|
||||
uint8_t i, j;
|
||||
uint16_t z;
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
z = 0;
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
z+=cube2[cube_surface[i].p[j]].z;
|
||||
}
|
||||
z/=4;
|
||||
cube_surface[i].z = z;
|
||||
//printf("%d: z=%d\n", i, z);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_cube(void)
|
||||
{
|
||||
uint8_t i, ii;
|
||||
uint8_t skip_cnt = 3; /* it is known, that the first 3 surfaces are invisible */
|
||||
int16_t z, z_upper;
|
||||
|
||||
|
||||
z_upper = 32767;
|
||||
for(;;)
|
||||
{
|
||||
ii = 6;
|
||||
z = -32767;
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
if ( cube_surface[i].z <= z_upper )
|
||||
{
|
||||
if ( z < cube_surface[i].z )
|
||||
{
|
||||
z = cube_surface[i].z;
|
||||
ii = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ii >= 6 )
|
||||
break;
|
||||
//printf("%d z=%d upper=%d\n", ii, z, z_upper);
|
||||
z_upper = cube_surface[ii].z;
|
||||
cube_surface[ii].z++;
|
||||
|
||||
if ( skip_cnt > 0 )
|
||||
{
|
||||
skip_cnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucg.setColor(0, ((ii+1)&1)*255,(((ii+1)>>1)&1)*255,(((ii+1)>>2)&1)*255);
|
||||
ucg.drawTetragon(
|
||||
cube_pt[cube_surface[ii].p[0]].x, cube_pt[cube_surface[ii].p[0]].y,
|
||||
cube_pt[cube_surface[ii].p[1]].x, cube_pt[cube_surface[ii].p[1]].y,
|
||||
cube_pt[cube_surface[ii].p[2]].x, cube_pt[cube_surface[ii].p[2]].y,
|
||||
cube_pt[cube_surface[ii].p[3]].x, cube_pt[cube_surface[ii].p[3]].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void calc_and_draw(uint16_t w, uint16_t v)
|
||||
{
|
||||
copy_cube();
|
||||
rotate_cube_y(w);
|
||||
rotate_cube_x(v);
|
||||
trans_cube(U*8);
|
||||
convert_cube();
|
||||
calculate_z();
|
||||
draw_cube();
|
||||
}
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setRotate90();
|
||||
ucg.clearScreen();
|
||||
ucg.setFont(ucg_font_ncenR10_tr);
|
||||
ucg.setPrintPos(0,25);
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.print("Ucglib Box3D");
|
||||
|
||||
}
|
||||
|
||||
uint16_t w = 0;
|
||||
uint16_t v = 0;
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
calc_and_draw(w, v>>3);
|
||||
|
||||
v+=3;
|
||||
v &= 511;
|
||||
|
||||
w++;
|
||||
w &= 63;
|
||||
delay(30);
|
||||
|
||||
ucg.setColor(0,0,0);
|
||||
ucg.drawBox(x_min, y_min, x_max-x_min+1, y_max-y_min+1);
|
||||
}
|
||||
|
||||
293
trunk/Arduino/libraries/Ucglib/examples/FPS/FPS.ino
Normal file
293
trunk/Arduino/libraries/Ucglib/examples/FPS/FPS.ino
Normal file
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
|
||||
FPS.ino
|
||||
|
||||
Do some speed measurements.
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
1 Feb 2014
|
||||
SSD1351, Arduino Due, HW SPI Text: 13.2 Box: 28.6 Gradient: 17.9
|
||||
SSD1351, Arduino Due, SW SPI Text: 11.1 Box: 17.3 Gradient: 12.9 1 May 2014: this has been reduced to get better signal quality
|
||||
SSD1351, Arduino Uno, HW SPI Text: 2.6 Box: 12.8 Gradient: 4.6
|
||||
SSD1351, Arduino Uno, SW SPI Text: 1.6 Box: 3.4 Gradient: 2.2
|
||||
|
||||
8 Feb 2014
|
||||
SSD1351, Arduino Uno, HW SPI Text: 5.0 Box: 15.2 Gradient: 5.3
|
||||
SSD1351, Arduino Uno, SW SPI Text: 2.7 Box: 3.4 Gradient: 2.2
|
||||
ILI9325, Arduino Uno, Port D Text: 5.8 Box: 17.5 Gradient: 5.5
|
||||
ILI9341, Arduino Due, SW SPI Text: 10.6 Box: 16.5 Gradient: 12.9 1 May 2014: this has been reduced to get better signal quality
|
||||
|
||||
28 Feb 2014
|
||||
PCF8833, Arduino Uno, HW SPI Text: 3.3 Box: 5.6 Gradient: 3.2
|
||||
PCF8833, Arduino Due, SW SPI Text: 1.3 Box: 1.3 Gradient: 1.2 (display errors)
|
||||
|
||||
27 Apr 2014, Issue 14 (SW SPI improvement)
|
||||
ST7735, Arduino Uno, SW SPI Text: 2.2 Box: 3.4 Gradient: 2.4
|
||||
|
||||
1 May 2014, (SW SPI speed reduced for Due)
|
||||
ST7735, Arduino Due, SW SPI Text: 4.9 Box: 4.9 Gradient: 4.4
|
||||
|
||||
11 Sep 2014
|
||||
ILI9341, Arduino Due, HW SPI Text: 12.4 Box: 22.4 Gradient: 16.5
|
||||
ILI9341, Arduino Due, SW SPI Text: 4.7 Box: 4.7 Gradient: 4.4
|
||||
|
||||
12 Sep 2014
|
||||
ILI9341, Arduino Due, HW SdSpi Text: 13.9 Box: 30.5 Gradient: 20.2 no multibyte transfer
|
||||
ILI9341, Arduino Due, HW SdSpi Text: 13.9 Box: 38.0 Gradient: 19.7 with multibyte transfer
|
||||
|
||||
1 mar 2015
|
||||
LD50T6160, Arduino Due, 6Bit Text: 6.4 Box: 13.1 Gradient: 10.5
|
||||
|
||||
23 May 2015, new font procedures
|
||||
ILI9341, Arduino Uno, SW SPI Text: 1.9 Box: 3.4 Gradient: 2.4
|
||||
ST7735, Arduino Uno, SW SPI Text: 2.0 Box: 3.4 Gradient: 2.4
|
||||
ST7735, Arduino Uno, HW SPI Text: 3.1 Box: 13.1 Gradient: 5.3
|
||||
|
||||
19 Jul 2015
|
||||
SSD1331, Arduino Uno, SW SPI Text: 3.8 Box: 6.3 Gradient: 4.2
|
||||
SSD1331, Arduino Uno, HW SPI Text: 6.0 Box: 27.3 Gradient: 8.8
|
||||
|
||||
21 Jul 2015
|
||||
SEPS225, Arduino Uno, SW SPI Text: 1.8 Box: 4.5 Gradient: 2.7
|
||||
SEPS225, Arduino Uno, HW SPI Text: 2.5 Box: 14.0 Gradient: 4.9
|
||||
|
||||
|
||||
25 Jul 2015 (improved speed for SEPS225)
|
||||
SEPS225, Arduino Uno, SW SPI Text: 2.6 Box: 5.0 Gradient: 2.9
|
||||
SEPS225, Arduino Uno, HW SPI Text: 3.8 Box: 17.8 Gradient: 5.3
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
|
||||
void setup(void) {
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setColor(0, 0,0,0);
|
||||
ucg.setColor(1, 0,0,0);
|
||||
ucg.setColor(2, 0,0,0);
|
||||
ucg.setColor(3, 0,0,0);
|
||||
}
|
||||
|
||||
/*
|
||||
Linear Congruential Generator (LCG)
|
||||
z = (a*z + c) % m;
|
||||
m = 256 (8 Bit)
|
||||
|
||||
for period:
|
||||
a-1: dividable by 2
|
||||
a-1: multiple of 4
|
||||
c: not dividable by 2
|
||||
|
||||
c = 17
|
||||
a-1 = 64 --> a = 65
|
||||
*/
|
||||
uint8_t z = 127; // start value
|
||||
uint8_t lcg_rnd(void) {
|
||||
z = (uint8_t)((uint16_t)65*(uint16_t)z + (uint16_t)17);
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void draw_text(void) {
|
||||
ucg.setFont(ucg_font_ncenR14_tr);
|
||||
//ucg.setColor(255, 255, 255);
|
||||
ucg.setColor(lcg_rnd(),lcg_rnd(),lcg_rnd());
|
||||
ucg.setPrintPos(0,20);
|
||||
ucg.print("The quick brown");
|
||||
ucg.setPrintPos(0,40);
|
||||
ucg.print("fox jumps over");
|
||||
ucg.setPrintPos(0,60);
|
||||
ucg.print("the lazy dog");
|
||||
}
|
||||
|
||||
void draw_box(void) {
|
||||
ucg_int_t x, y, w, h;
|
||||
ucg.setColor(lcg_rnd(),lcg_rnd(),lcg_rnd());
|
||||
x = lcg_rnd() & 31;
|
||||
y = lcg_rnd() & 31;
|
||||
w = 63;
|
||||
w += lcg_rnd() & 31;
|
||||
h = 63;
|
||||
h += lcg_rnd() & 31;
|
||||
ucg.drawBox(x,y,w, h);
|
||||
}
|
||||
|
||||
void draw_gradient_box(void) {
|
||||
ucg_int_t x, y, w, h;
|
||||
static uint8_t idx = 0;
|
||||
switch(idx & 3)
|
||||
{
|
||||
case 0: ucg.setColor(0, lcg_rnd(),lcg_rnd(),lcg_rnd()); break;
|
||||
case 1: ucg.setColor(1, lcg_rnd(),lcg_rnd(),lcg_rnd()); break;
|
||||
case 2: ucg.setColor(2, lcg_rnd(),lcg_rnd(),lcg_rnd()); break;
|
||||
case 3: ucg.setColor(3, lcg_rnd(),lcg_rnd(),lcg_rnd()); break;
|
||||
}
|
||||
idx++;
|
||||
x = lcg_rnd() & 31;
|
||||
y = lcg_rnd() & 31;
|
||||
w = 63;
|
||||
w += lcg_rnd() & 31;
|
||||
h = 63;
|
||||
h += lcg_rnd() & 31;
|
||||
ucg.drawGradientBox(x,y,w, h);
|
||||
}
|
||||
|
||||
|
||||
// returns FPS*10
|
||||
uint16_t measure(void (*draw_fn)(void)) {
|
||||
uint16_t FPS10 = 0;
|
||||
uint32_t time;
|
||||
|
||||
ucg.clearScreen();
|
||||
|
||||
time = millis() + 10*1000;
|
||||
do {
|
||||
draw_fn();
|
||||
FPS10++;
|
||||
} while( millis() < time );
|
||||
|
||||
return FPS10;
|
||||
}
|
||||
|
||||
|
||||
static const unsigned char u8d_tab[3] = { 100, 10, 1 } ;
|
||||
const char *u8dp(char * dest, uint8_t v)
|
||||
{
|
||||
uint8_t pos;
|
||||
uint8_t d;
|
||||
uint8_t c;
|
||||
for( pos = 0; pos < 3; pos++ )
|
||||
{
|
||||
d = '0';
|
||||
c = *(u8d_tab+pos);
|
||||
while( v >= c )
|
||||
{
|
||||
v -= c;
|
||||
d++;
|
||||
}
|
||||
dest[pos] = d;
|
||||
}
|
||||
dest[3] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* v = value, d = number of digits */
|
||||
const char *u8d(uint8_t v, uint8_t d)
|
||||
{
|
||||
static char buf[8];
|
||||
d = 3-d;
|
||||
return u8dp(buf, v) + d;
|
||||
}
|
||||
|
||||
const char *convert_FPS(uint16_t fps) {
|
||||
static char buf[6];
|
||||
strcpy(buf, u8d( (uint8_t)(fps/10), 3));
|
||||
buf[3] = '.';
|
||||
buf[4] = (fps % 10) + '0';
|
||||
buf[5] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
void show_result(const char *s, uint16_t fps) {
|
||||
ucg.clearScreen();
|
||||
ucg.setFont(ucg_font_helvR18_tr);
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(0,25);
|
||||
ucg.print(s);
|
||||
ucg.setPrintPos(0,50);
|
||||
ucg.print(convert_FPS(fps));
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
show_result("Text", measure(draw_text));
|
||||
show_result("Box", measure(draw_box));
|
||||
show_result("Gradient", measure(draw_gradient_box));
|
||||
delay(500);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,583 @@
|
||||
/*
|
||||
|
||||
GraphicsTest.ino
|
||||
|
||||
Generate some example graphics
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
#define T 4000
|
||||
#define DLY() delay(2000)
|
||||
|
||||
/*
|
||||
Linear Congruential Generator (LCG)
|
||||
z = (a*z + c) % m;
|
||||
m = 256 (8 Bit)
|
||||
|
||||
for period:
|
||||
a-1: dividable by 2
|
||||
a-1: multiple of 4
|
||||
c: not dividable by 2
|
||||
|
||||
c = 17
|
||||
a-1 = 64 --> a = 65
|
||||
*/
|
||||
uint8_t z = 127; // start value
|
||||
uint32_t lcg_rnd(void) {
|
||||
z = (uint8_t)((uint16_t)65*(uint16_t)z + (uint16_t)17);
|
||||
return (uint32_t)z;
|
||||
}
|
||||
|
||||
|
||||
void ucglib_graphics_test(void)
|
||||
{
|
||||
//ucg.setMaxClipRange();
|
||||
ucg.setColor(0, 0, 40, 80);
|
||||
ucg.setColor(1, 80, 0, 40);
|
||||
ucg.setColor(2, 255, 0, 255);
|
||||
ucg.setColor(3, 0, 255, 255);
|
||||
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 168, 0);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.print("Ucglib");
|
||||
ucg.setPrintPos(2,18+20);
|
||||
ucg.print("GraphicsTest");
|
||||
|
||||
DLY();
|
||||
}
|
||||
|
||||
void gradient(void)
|
||||
{
|
||||
ucg.setColor(0, 0, 255, 0);
|
||||
ucg.setColor(1, 255, 0, 0);
|
||||
ucg.setColor(2, 255, 0, 255);
|
||||
ucg.setColor(3, 0, 255, 255);
|
||||
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("GradientBox");
|
||||
|
||||
ucg.setColor(0, 0, 255, 0);
|
||||
ucg.drawBox(2, 25, 8, 8);
|
||||
|
||||
ucg.setColor(0, 255, 0, 0);
|
||||
ucg.drawBox(2+10, 25, 8, 8);
|
||||
|
||||
ucg.setColor(0, 255, 0, 255);
|
||||
ucg.drawBox(2, 25+10, 8, 8);
|
||||
|
||||
ucg.setColor(0, 0, 255, 255);
|
||||
ucg.drawBox(2+10, 25+10, 8, 8);
|
||||
|
||||
DLY();
|
||||
}
|
||||
|
||||
void box(void)
|
||||
{
|
||||
ucg_int_t x, y, w, h;
|
||||
unsigned long m;
|
||||
|
||||
ucg.setColor(0, 0, 40, 80);
|
||||
ucg.setColor(1, 60, 0, 40);
|
||||
ucg.setColor(2, 128, 0, 140);
|
||||
ucg.setColor(3, 0, 128, 140);
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Box");
|
||||
|
||||
m = millis() + T;
|
||||
|
||||
while( millis() < m )
|
||||
{
|
||||
ucg.setColor((lcg_rnd()&127)+127, (lcg_rnd()&127)+64, lcg_rnd() & 31);
|
||||
w = lcg_rnd() & 31;
|
||||
h = lcg_rnd() & 31;
|
||||
w += 10;
|
||||
h += 10;
|
||||
x = (lcg_rnd()*(ucg.getWidth()-w))>>8;
|
||||
y = (lcg_rnd()*(ucg.getHeight()-h-20))>>8;
|
||||
|
||||
ucg.drawBox(x, y+20, w, h);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void pixel_and_lines(void)
|
||||
{
|
||||
ucg_int_t mx;
|
||||
ucg_int_t x, xx;
|
||||
mx = ucg.getWidth() / 2;
|
||||
//my = ucg.getHeight() / 2;
|
||||
|
||||
ucg.setColor(0, 0, 0, 150);
|
||||
ucg.setColor(1, 0, 60, 40);
|
||||
ucg.setColor(2, 60, 0, 40);
|
||||
ucg.setColor(3, 120, 120, 200);
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Pix&Line");
|
||||
|
||||
ucg.drawPixel(0, 0);
|
||||
ucg.drawPixel(1, 0);
|
||||
//ucg.drawPixel(ucg.getWidth()-1, 0);
|
||||
//ucg.drawPixel(0, ucg.getHeight()-1);
|
||||
|
||||
ucg.drawPixel(ucg.getWidth()-1, ucg.getHeight()-1);
|
||||
ucg.drawPixel(ucg.getWidth()-1-1, ucg.getHeight()-1);
|
||||
|
||||
|
||||
for( x = 0; x < mx; x++ )
|
||||
{
|
||||
xx = (((uint16_t)x)*255)/mx;
|
||||
ucg.setColor(255, 255-xx/2, 255-xx);
|
||||
ucg.drawPixel(x, 24);
|
||||
ucg.drawVLine(x+7, 26, 13);
|
||||
}
|
||||
|
||||
DLY();
|
||||
}
|
||||
|
||||
void color_test(void)
|
||||
{
|
||||
ucg_int_t mx;
|
||||
uint16_t c, x;
|
||||
mx = ucg.getWidth() / 2;
|
||||
//my = ucg.getHeight() / 2;
|
||||
|
||||
ucg.setColor(0, 0, 0, 0);
|
||||
ucg.drawBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Color Test");
|
||||
|
||||
ucg.setColor(0, 127, 127, 127);
|
||||
ucg.drawBox(0, 20, 16*4+4, 5*8+4);
|
||||
|
||||
for( c = 0, x = 2; c <= 255; c+=17, x+=4 )
|
||||
{
|
||||
ucg.setColor(0, c, c, c);
|
||||
ucg.drawBox(x, 22, 4, 8);
|
||||
ucg.setColor(0, c, 0, 0);
|
||||
ucg.drawBox(x, 22+8, 4, 8);
|
||||
ucg.setColor(0, 0, c, 0);
|
||||
ucg.drawBox(x, 22+2*8, 4, 8);
|
||||
ucg.setColor(0, 0, 0, c);
|
||||
ucg.drawBox(x, 22+3*8, 4, 8);
|
||||
ucg.setColor(0, c, 255-c, 0);
|
||||
ucg.drawBox(x, 22+4*8, 4, 8);
|
||||
|
||||
}
|
||||
|
||||
DLY();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cross(void)
|
||||
{
|
||||
ucg_int_t mx, my;
|
||||
ucg.setColor(0, 250, 0, 0);
|
||||
ucg.setColor(1, 255, 255, 30);
|
||||
ucg.setColor(2, 220, 235, 10);
|
||||
ucg.setColor(3, 205, 0, 30);
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
mx = ucg.getWidth() / 2;
|
||||
my = ucg.getHeight() / 2;
|
||||
|
||||
ucg.setColor(0, 255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.print("Cross");
|
||||
|
||||
ucg.setColor(0, 0, 0x66, 0xcc);
|
||||
ucg.setPrintPos(mx+15,my-5);
|
||||
ucg.print("dir0");
|
||||
ucg.setPrintPos(mx+5,my+26);
|
||||
ucg.print("dir1");
|
||||
ucg.setPrintPos(mx-40,my+20);
|
||||
ucg.print("dir2");
|
||||
ucg.setPrintPos(mx+5,my-25);
|
||||
ucg.print("dir3");
|
||||
|
||||
ucg.setColor(0, 0, 0x66, 0xff);
|
||||
ucg.setColor(1, 0, 0x66, 0xcc);
|
||||
ucg.setColor(2, 0, 0, 0x99);
|
||||
|
||||
ucg_Draw90Line(ucg.getUcg(), mx+2, my-1, 20, 0, 0);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx+2, my, 20, 0, 1);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx+2, my+1, 20, 0, 2);
|
||||
|
||||
ucg_Draw90Line(ucg.getUcg(), mx+1, my+2, 20, 1, 0);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx, my+2, 20, 1, 1);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx-1, my+2, 20, 1, 2);
|
||||
|
||||
ucg_Draw90Line(ucg.getUcg(), mx-2, my+1, 20, 2, 0);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx-2, my, 20, 2, 1);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx-2, my-1, 20, 2, 2);
|
||||
|
||||
ucg_Draw90Line(ucg.getUcg(), mx-1, my-2, 20, 3, 0);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx, my-2, 20, 3, 1);
|
||||
ucg_Draw90Line(ucg.getUcg(), mx+1, my-2, 20, 3, 2);
|
||||
|
||||
DLY();
|
||||
}
|
||||
|
||||
void triangle(void)
|
||||
{
|
||||
unsigned long m;
|
||||
|
||||
ucg.setColor(0, 0, 80, 20);
|
||||
ucg.setColor(1, 60, 80, 20);
|
||||
ucg.setColor(2, 60, 120, 0);
|
||||
ucg.setColor(3, 0, 140, 30);
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.print("Triangle");
|
||||
|
||||
m = millis() + T;
|
||||
|
||||
while( millis() < m )
|
||||
{
|
||||
ucg.setColor((lcg_rnd()&127)+127, lcg_rnd() & 31, (lcg_rnd()&127)+64);
|
||||
|
||||
ucg.drawTriangle(
|
||||
(lcg_rnd()*(ucg.getWidth()))>>8,
|
||||
((lcg_rnd()*(ucg.getHeight()-20))>>8)+20,
|
||||
(lcg_rnd()*(ucg.getWidth()))>>8,
|
||||
((lcg_rnd()*(ucg.getHeight()-20))>>8)+20,
|
||||
(lcg_rnd()*(ucg.getWidth()))>>8,
|
||||
((lcg_rnd()*(ucg.getHeight()-20))>>8)+20
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void text(void)
|
||||
{
|
||||
ucg_int_t x, y, w, h, i;
|
||||
unsigned long m;
|
||||
|
||||
ucg.setColor(0, 80, 40, 0);
|
||||
ucg.setColor(1, 60, 0, 40);
|
||||
ucg.setColor(2, 20, 0, 20);
|
||||
ucg.setColor(3, 60, 0, 0);
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Text");
|
||||
|
||||
m = millis() + T;
|
||||
i = 0;
|
||||
while( millis() < m )
|
||||
{
|
||||
ucg.setColor(lcg_rnd() & 31, (lcg_rnd()&127)+127, (lcg_rnd()&127)+64);
|
||||
w = 40;
|
||||
h = 22;
|
||||
x = (lcg_rnd()*(ucg.getWidth()-w))>>8;
|
||||
y = (lcg_rnd()*(ucg.getHeight()-h))>>8;
|
||||
|
||||
ucg.setPrintPos(x,y+h);
|
||||
ucg.setPrintDir((i>>2)&3);
|
||||
i++;
|
||||
ucg.print("Ucglib");
|
||||
}
|
||||
ucg.setPrintDir(0);
|
||||
|
||||
}
|
||||
|
||||
void fonts(void)
|
||||
{
|
||||
ucg_int_t d = 5;
|
||||
ucg.setColor(0, 0, 40, 80);
|
||||
ucg.setColor(1, 150, 0, 200);
|
||||
ucg.setColor(2, 60, 0, 40);
|
||||
ucg.setColor(3, 0, 160, 160);
|
||||
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.print("Fonts");
|
||||
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
|
||||
ucg.setColor(255, 200, 170);
|
||||
ucg.setFont(ucg_font_helvB08_hr);
|
||||
ucg.setPrintPos(2,30+d);
|
||||
ucg.print("ABC abc 123");
|
||||
ucg.setFont(ucg_font_helvB10_hr);
|
||||
ucg.setPrintPos(2,45+d);
|
||||
ucg.print("ABC abc 123");
|
||||
ucg.setFont(ucg_font_helvB12_hr);
|
||||
//ucg.setPrintPos(2,62+d);
|
||||
//ucg.print("ABC abc 123");
|
||||
ucg.drawString(2,62+d, 0, "ABC abc 123"); // test drawString
|
||||
|
||||
ucg.setFontMode(UCG_FONT_MODE_SOLID);
|
||||
|
||||
ucg.setColor(255, 200, 170);
|
||||
ucg.setColor(1, 0, 100, 120); // background color in solid mode
|
||||
ucg.setFont(ucg_font_helvB08_hr);
|
||||
ucg.setPrintPos(2,75+30+d);
|
||||
ucg.print("ABC abc 123");
|
||||
ucg.setFont(ucg_font_helvB10_hr);
|
||||
ucg.setPrintPos(2,75+45+d);
|
||||
ucg.print("ABC abc 123");
|
||||
ucg.setFont(ucg_font_helvB12_hr);
|
||||
ucg.setPrintPos(2,75+62+d);
|
||||
ucg.print("ABC abc 123");
|
||||
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
|
||||
/* big fonts removed, some trouble with the Arduino IDE */
|
||||
/*
|
||||
ucg.setFont(ucg_font_helvB14_hr);
|
||||
ucg.setPrintPos(2,79+d);
|
||||
ucg.print("ABC abc 123");
|
||||
ucg.setFont(ucg_font_helvB18_hr);
|
||||
ucg.setPrintPos(2,79+22+d);
|
||||
ucg.print("ABC abc 123");
|
||||
*/
|
||||
|
||||
ucg.setFont(ucg_font_ncenR14_hr);
|
||||
DLY();
|
||||
}
|
||||
|
||||
void clip(void)
|
||||
{
|
||||
ucg.setColor(0, 0x00, 0xd1, 0x5e); // dark green
|
||||
ucg.setColor(1, 0xff, 0xf7, 0x61); // yellow
|
||||
ucg.setColor(2, 0xd1, 0xc7, 0x00); // dark yellow
|
||||
ucg.setColor(3, 0x61, 0xff, 0xa8); // green
|
||||
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setPrintPos(2,18);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("ClipRange");
|
||||
|
||||
ucg.setColor(0xd1, 0x00, 0x073);
|
||||
|
||||
ucg.setFont(ucg_font_helvB18_hr);
|
||||
|
||||
ucg.setPrintPos(25,45);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(1);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(2);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(3);
|
||||
ucg.print("Ucg");
|
||||
|
||||
|
||||
ucg.setMaxClipRange();
|
||||
ucg.setColor(0xff, 0xff, 0xff);
|
||||
ucg.drawFrame(20-1,30-1,15+2,20+2);
|
||||
ucg.setClipRange(20, 30, 15, 20);
|
||||
ucg.setColor(0xff, 0x61, 0x0b8);
|
||||
ucg.setPrintPos(25,45);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(1);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(2);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(3);
|
||||
ucg.print("Ucg");
|
||||
|
||||
|
||||
ucg.setMaxClipRange();
|
||||
ucg.setColor(0xff, 0xff, 0xff);
|
||||
ucg.drawFrame(60-1,35-1,25+2,18+2);
|
||||
ucg.setClipRange(60, 35, 25, 18);
|
||||
ucg.setColor(0xff, 0x61, 0x0b8);
|
||||
ucg.setPrintPos(25,45);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(1);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(2);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(3);
|
||||
ucg.print("Ucg");
|
||||
|
||||
ucg.setMaxClipRange();
|
||||
ucg.setColor(0xff, 0xff, 0xff);
|
||||
ucg.drawFrame(7-1,58-1,90+2,4+2);
|
||||
ucg.setClipRange(7, 58, 90, 4);
|
||||
ucg.setColor(0xff, 0x61, 0x0b8);
|
||||
ucg.setPrintPos(25,45);
|
||||
ucg.setPrintDir(0);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(1);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(2);
|
||||
ucg.print("Ucg");
|
||||
ucg.setPrintDir(3);
|
||||
ucg.print("Ucg");
|
||||
|
||||
ucg.setFont(ucg_font_ncenR14_hr);
|
||||
ucg.setMaxClipRange();
|
||||
DLY();
|
||||
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setFont(ucg_font_ncenR14_hr);
|
||||
ucg.clearScreen();
|
||||
}
|
||||
|
||||
void set_clip_range(void)
|
||||
{
|
||||
ucg_int_t x, y, w, h;
|
||||
w = lcg_rnd() & 31;
|
||||
h = lcg_rnd() & 31;
|
||||
w += 25;
|
||||
h += 25;
|
||||
x = (lcg_rnd()*(ucg.getWidth()-w))>>8;
|
||||
y = (lcg_rnd()*(ucg.getHeight()-h))>>8;
|
||||
|
||||
ucg.setClipRange(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
uint8_t r = 0;
|
||||
void loop(void)
|
||||
{
|
||||
switch(r&3)
|
||||
{
|
||||
case 0: ucg.undoRotate(); break;
|
||||
case 1: ucg.setRotate90(); break;
|
||||
case 2: ucg.setRotate180(); break;
|
||||
default: ucg.setRotate270(); break;
|
||||
}
|
||||
|
||||
if ( r > 3 )
|
||||
{
|
||||
ucg.clearScreen();
|
||||
set_clip_range();
|
||||
}
|
||||
|
||||
r++;
|
||||
ucglib_graphics_test();
|
||||
cross();
|
||||
pixel_and_lines();
|
||||
color_test();
|
||||
triangle();
|
||||
fonts();
|
||||
text();
|
||||
if ( r <= 3 )
|
||||
clip();
|
||||
box();
|
||||
gradient();
|
||||
//ucg.clearScreen();
|
||||
DLY();
|
||||
ucg.setMaxClipRange();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
|
||||
HelloWorld.ino
|
||||
|
||||
A very simple example for Ucglib
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
18 Feb 2014:
|
||||
ROM Size Font Mode
|
||||
9928 NONE
|
||||
10942 TRANSPARENT (1014 Bytes)
|
||||
11650 SOLID (1712 Bytes)
|
||||
12214 TRANSPARENT+SOLID
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 17, /*cd=*/ 16, /*cs=*/ 0, /*reset=*/ 2); /* FT SSD1351 direct connect to ESP32 */
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
|
||||
//ucg.begin(UCG_FONT_MODE_SOLID);
|
||||
ucg.clearScreen();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
//ucg.setRotate90();
|
||||
ucg.setFont(ucg_font_ncenR12_tr);
|
||||
ucg.setColor(255, 255, 255);
|
||||
//ucg.setColor(0, 255, 0);
|
||||
ucg.setColor(1, 255, 0,0);
|
||||
|
||||
ucg.setPrintPos(0,25);
|
||||
ucg.print("Hello World!");
|
||||
|
||||
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
|
||||
HowToUseFonts.ino
|
||||
|
||||
A demonstration on how to use the different types of fonts.
|
||||
The following fonts will be used:
|
||||
ucg_font_helvB08_hr
|
||||
ucg_font_helvB08_tr
|
||||
ucg_font_amstrad_cpc_8r
|
||||
Good and bad examples are shown.
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
|
||||
/*
|
||||
Linear Congruential Generator (LCG)
|
||||
z = (a*z + c) % m;
|
||||
m = 256 (8 Bit)
|
||||
|
||||
for period:
|
||||
a-1: dividable by 2
|
||||
a-1: multiple of 4
|
||||
c: not dividable by 2
|
||||
|
||||
c = 17
|
||||
a-1 = 64 --> a = 65
|
||||
*/
|
||||
uint8_t z = 127; // start value
|
||||
uint32_t lcg_rnd(void) {
|
||||
z = (uint8_t)((uint16_t)65*(uint16_t)z + (uint16_t)17);
|
||||
return (uint32_t)z;
|
||||
}
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
|
||||
|
||||
ucg.setColor(0, 120, 0, 0);
|
||||
ucg.setColor(2, 0, 120, 0);
|
||||
ucg.setColor(1, 120, 0, 120);
|
||||
ucg.setColor(3, 0, 120, 120);
|
||||
|
||||
ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
// get a random value between 0 and 255
|
||||
uint8_t rnd = lcg_rnd();
|
||||
ucg_int_t y = 0;
|
||||
ucg_int_t h = 14;
|
||||
|
||||
|
||||
// You can not overwrite the previous number with a transparent font
|
||||
y += h;
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("Does not work:");
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
|
||||
// Using the same transparent font in solid mode works better,
|
||||
// but still some pixel are not overwritten
|
||||
y += h;
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("Pixel errors:");
|
||||
ucg.setFontMode(UCG_FONT_MODE_SOLID);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setColor(1, 64, 64, 255); // use blue as background for SOLID mode
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
|
||||
// Using the "h" or "m" type of font in solid mode will almost work
|
||||
// however, if the number changes from 100 to 99, the last number
|
||||
// will not be overwritten.
|
||||
y += h;
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("Value errors:");
|
||||
ucg.setFontMode(UCG_FONT_MODE_SOLID);
|
||||
ucg.setFont(ucg_font_helvB08_hr);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setColor(1, 64, 64, 255); // use blue as background for SOLID mode
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
|
||||
// Using the "h" or "m" type of font in solid mode will work fine, if
|
||||
// there are extra spaced after the string to overwrite the previous value.
|
||||
// As long as a "h" font is used, the number of spaces is not fixed.
|
||||
// This means, even two spaced my not be sufficent. Better use a monospace font.
|
||||
y += h;
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("Almost ok:");
|
||||
ucg.setFontMode(UCG_FONT_MODE_SOLID);
|
||||
ucg.setFont(ucg_font_helvB08_hr);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setColor(1, 64, 64, 255); // use blue as background for SOLID mode
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
ucg.print(" "); // two extra spaces (not sufficient here)
|
||||
|
||||
// The transparent font and mode can be used, if the previous content
|
||||
// is fully erased or overwritten
|
||||
y += h;
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("Manual erase:");
|
||||
ucg.setColor(0, 255, 40, 80);
|
||||
ucg.setColor(1, 0, 255, 0);
|
||||
ucg.setColor(2, 255, 0, 0);
|
||||
ucg.setColor(3, 65, 255, 40);
|
||||
ucg.drawGradientBox(80-2, y-10, 22, 12); // red to green bar will erase the previous value
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
|
||||
// The is will use the solid font with the extra spaces to erase the previous value
|
||||
// A monospaced 8x8 pixel font is used (here: ucg_font_amstrad_cpc_8r).
|
||||
y += h;
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("8x8 font:");
|
||||
ucg.setFontMode(UCG_FONT_MODE_SOLID);
|
||||
ucg.setFont(ucg_font_amstrad_cpc_8r);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setColor(1, 64, 64, 255); // use blue as background for SOLID mode
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
ucg.print(" "); // extra spaces
|
||||
|
||||
// The is will use the solid font with the extra spaces to erase the previous value
|
||||
// Any monospaced font can be used (here: ucg_font_7x13_mr).
|
||||
y += h;
|
||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.setPrintPos(4,y);
|
||||
ucg.setFont(ucg_font_helvB08_tr);
|
||||
ucg.print("_mr font:");
|
||||
ucg.setFontMode(UCG_FONT_MODE_SOLID);
|
||||
ucg.setFont(ucg_font_7x13_mr);
|
||||
ucg.setColor(0, 255, 255, 255); // use white as main color for the font
|
||||
ucg.setColor(1, 64, 64, 255); // use blue as background for SOLID mode
|
||||
ucg.setPrintPos(80,y);
|
||||
ucg.print(rnd);
|
||||
ucg.print(" "); // extra spaces
|
||||
|
||||
|
||||
delay(100);
|
||||
}
|
||||
112
trunk/Arduino/libraries/Ucglib/examples/Scale/Scale.ino
Normal file
112
trunk/Arduino/libraries/Ucglib/examples/Scale/Scale.ino
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
|
||||
HelloWorld.ino
|
||||
|
||||
A very simple example for Ucglib
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_SOLID);
|
||||
ucg.clearScreen();
|
||||
ucg.setRotate90();
|
||||
ucg.setScale2x2();
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
void loop(void)
|
||||
{
|
||||
ucg.setFont(ucg_font_logisoso22r);
|
||||
ucg.setPrintPos(0,30);
|
||||
ucg.setColor(255, 255, 255);
|
||||
ucg.setColor(1, 255, 0, 0);
|
||||
ucg.print(n);
|
||||
delay(1000);
|
||||
n++;
|
||||
}
|
||||
|
||||
258
trunk/Arduino/libraries/Ucglib/examples/UcgLogo/UcgLogo.ino
Normal file
258
trunk/Arduino/libraries/Ucglib/examples/UcgLogo/UcgLogo.ino
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
|
||||
UcgLogo.ino
|
||||
|
||||
Draw the Ucglib Logo
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Ucglib.h"
|
||||
|
||||
/*
|
||||
Hardware SPI Pins:
|
||||
Arduino Uno sclk=13, data=11
|
||||
Arduino Due sclk=76, data=75
|
||||
Arduino Mega sclk=52, data=51
|
||||
|
||||
>>> Please uncomment (and update) one of the following constructors. <<<
|
||||
*/
|
||||
//Ucglib8BitPortD ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
//Ucglib8Bit ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, 0, 1, 2, 3, 4, 5, 6, 7, /* wr= */ 18 , /* cd= */ 19 , /* cs= */ 17, /* reset= */ 16 );
|
||||
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib4WireSWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9 , /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_spi_18x240x320, ucg_ext_ili9325_spi_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
//Ucglib3WireILI9325SWSPI ucg(ucg_dev_ili9325_18x240x320_itdb02, ucg_ext_ili9325_18, /*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 10, /*reset=*/ 8); // not working
|
||||
|
||||
//Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9163_18x128x128_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9163_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8); /* HW SPI Adapter */
|
||||
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 4, /*data=*/ 3, /*cd=*/ 6, /*cs=*/ 7, /*reset=*/ 5); /* Elec Freaks Shield */
|
||||
|
||||
//Ucglib_HX8352C_18x240x400_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_HX8352C_18x240x400_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_ILI9486_18x320x480_SWSPI ucg(/*sclk=*/ 7, /*data=*/ 6, /*cd=*/ 5, /*cs=*/ 3, /*reset=*/ 4);
|
||||
//Ucglib_ILI9486_18x320x480_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SSD1351_18x128x128_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1351_18x128x128_FT_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_PCF8833_16x132x132_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
//Ucglib_PCF8833_16x132x132_HWSPI ucg(/*cs=*/ 9, /*reset=*/ 8); /* linksprite board */
|
||||
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ d0, /*d1 =*/ d1, /*d2 =*/ d2, /*d3 =*/ d3, /*d4 =*/ d4, /*d5 =*/ d5, /*wr=*/ wr, /*cd=*/ cd, /*cs=*/ cs, /*reset=*/ reset);
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 16, /*d1 =*/ 17, /*d2 =*/ 18, /*d3 =*/ 19, /*d4 =*/ 20, /*d5 =*/ 21, /*wr=*/ 14, /*cd=*/ 15); /* Samsung 160x128 OLED with 6Bit minimal interface with Due */
|
||||
//Ucglib_LD50T6160_18x160x128_6Bit ucg( /*d0 =*/ 5, /*d1 =*/ 4, /*d2 =*/ 3, /*d3 =*/ 2, /*d4 =*/ 1, /*d5 =*/ 0, /*wr=*/ 7, /*cd=*/ 6); /* Samsung 160x128 OLED with 6Bit minimal interface with Uno */
|
||||
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SSD1331_18x96x64_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
//Ucglib_SEPS225_16x128x128_UNIVISION_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||
|
||||
|
||||
void upper_pin(ucg_t *ucg, ucg_int_t x, ucg_int_t y)
|
||||
{
|
||||
ucg_int_t w = 7;
|
||||
ucg_int_t h = 6;
|
||||
ucg_SetColor(ucg, 0, 212, 212, 212);
|
||||
ucg_SetColor(ucg, 1, 200, 200, 200);
|
||||
ucg_SetColor(ucg, 2, 200, 200, 200);
|
||||
ucg_SetColor(ucg, 3, 188, 188, 188);
|
||||
ucg_DrawGradientBox(ucg, x, y, w, h);
|
||||
|
||||
//ucg_DrawVLine(ucg, x+w, y+1, len);
|
||||
ucg_SetColor(ucg, 0, 220, 220, 220);
|
||||
ucg_SetColor(ucg, 1, 232, 232, 232);
|
||||
ucg_DrawGradientLine(ucg, x+w, y, h, 1);
|
||||
}
|
||||
|
||||
void lower_pin(ucg_t *ucg, ucg_int_t x, ucg_int_t y)
|
||||
{
|
||||
ucg_int_t w = 7;
|
||||
ucg_int_t h = 5;
|
||||
ucg_SetColor(ucg, 0, 212, 212, 212);
|
||||
ucg_SetColor(ucg, 1, 200, 200, 200);
|
||||
ucg_SetColor(ucg, 2, 200, 200, 200);
|
||||
ucg_SetColor(ucg, 3, 188, 188, 188);
|
||||
ucg_DrawGradientBox(ucg, x, y, w, h);
|
||||
|
||||
//ucg_DrawVLine(ucg, x+w, y+1, len);
|
||||
ucg_SetColor(ucg, 0, 220, 220, 220);
|
||||
ucg_SetColor(ucg, 1, 232, 232, 232);
|
||||
ucg_DrawGradientLine(ucg, x+w, y, h, 1);
|
||||
ucg_SetColor(ucg, 0, 220, 220, 220);
|
||||
ucg_SetColor(ucg, 1, 232, 232, 232);
|
||||
ucg_DrawGradientLine(ucg, x, y+h, w, 0);
|
||||
ucg_SetColor(ucg, 0, 240, 240, 240);
|
||||
ucg_DrawPixel(ucg, x+w, y+h);
|
||||
}
|
||||
|
||||
void ic_body(ucg_t *ucg, ucg_int_t x, ucg_int_t y)
|
||||
{
|
||||
ucg_int_t w = 4*14+4;
|
||||
ucg_int_t h = 31;
|
||||
ucg_SetColor(ucg, 0, 60, 60, 60);
|
||||
ucg_SetColor(ucg, 1, 40, 40, 40);
|
||||
ucg_SetColor(ucg, 2, 48, 48, 48);
|
||||
ucg_SetColor(ucg, 3, 30, 30, 30);
|
||||
ucg_DrawGradientBox(ucg, x, y, w, h);
|
||||
|
||||
ucg_SetColor(ucg, 0, 255, 168, 0);
|
||||
//ucg_SetColor(ucg, 0, 225, 168, 30);
|
||||
ucg_DrawDisc(ucg, x+w-1, y+h/2-1, 7, UCG_DRAW_UPPER_LEFT|UCG_DRAW_LOWER_LEFT);
|
||||
|
||||
ucg_SetColor(ucg, 0, 60, 30, 0);
|
||||
//ucg_DrawDisc(ucg, x+w-1, y+h/2+1, 7, UCG_DRAW_UPPER_LEFT|UCG_DRAW_LOWER_LEFT);
|
||||
|
||||
ucg_SetColor(ucg, 0, 50, 50, 50);
|
||||
ucg_SetColor(ucg, 0, 25, 25, 25);
|
||||
ucg_DrawDisc(ucg, x+w-1, y+h/2+1, 7, UCG_DRAW_UPPER_LEFT|UCG_DRAW_LOWER_LEFT);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void draw_ucg_logo(ucg_t *ucg)
|
||||
{
|
||||
ucg_int_t a,b;
|
||||
|
||||
//ucg_Init(ucg, ucg_sdl_dev_cb, ucg_ext_none, (ucg_com_fnptr)0);
|
||||
ucg_SetFont(ucg, ucg_font_ncenB24_tr);
|
||||
|
||||
//ucg_SetRotate270(ucg);
|
||||
//ucg_SetClipRange(ucg, 10,5,40,20);
|
||||
|
||||
|
||||
|
||||
a = 2;
|
||||
b = 3;
|
||||
|
||||
ucg_SetColor(ucg, 0, 135*a/b,206*a/b,250*a/b);
|
||||
ucg_SetColor(ucg, 1, 176*a/b,226*a/b,255*a/b);
|
||||
ucg_SetColor(ucg, 2, 25*a/b,25*a/b,112*a/b);
|
||||
ucg_SetColor(ucg, 3, 85*a/b,26*a/b,139*a/b);
|
||||
ucg_DrawGradientBox(ucg, 0, 0, ucg_GetWidth(ucg)/4, ucg_GetHeight(ucg));
|
||||
|
||||
ucg_SetColor(ucg, 1, 135*a/b,206*a/b,250*a/b);
|
||||
ucg_SetColor(ucg, 0, 176*a/b,226*a/b,255*a/b);
|
||||
ucg_SetColor(ucg, 3, 25*a/b,25*a/b,112*a/b);
|
||||
ucg_SetColor(ucg, 2, 85*a/b,26*a/b,139*a/b);
|
||||
ucg_DrawGradientBox(ucg, ucg_GetWidth(ucg)/4, 0, ucg_GetWidth(ucg)/4, ucg_GetHeight(ucg));
|
||||
|
||||
ucg_SetColor(ucg, 0, 135*a/b,206*a/b,250*a/b);
|
||||
ucg_SetColor(ucg, 1, 176*a/b,226*a/b,255*a/b);
|
||||
ucg_SetColor(ucg, 2, 25*a/b,25*a/b,112*a/b);
|
||||
ucg_SetColor(ucg, 3, 85*a/b,26*a/b,139*a/b);
|
||||
ucg_DrawGradientBox(ucg, ucg_GetWidth(ucg)*2/4, 0, ucg_GetWidth(ucg)/4, ucg_GetHeight(ucg));
|
||||
|
||||
ucg_SetColor(ucg, 1, 135*a/b,206*a/b,250*a/b);
|
||||
ucg_SetColor(ucg, 0, 176*a/b,226*a/b,255*a/b);
|
||||
ucg_SetColor(ucg, 3, 25*a/b,25*a/b,112*a/b);
|
||||
ucg_SetColor(ucg, 2, 85*a/b,26*a/b,139*a/b);
|
||||
ucg_DrawGradientBox(ucg, ucg_GetWidth(ucg)*3/4, 0, ucg_GetWidth(ucg)/4, ucg_GetHeight(ucg));
|
||||
|
||||
|
||||
upper_pin(ucg, 7+0*14, 4);
|
||||
upper_pin(ucg, 7+1*14, 4);
|
||||
upper_pin(ucg, 7+2*14, 4);
|
||||
upper_pin(ucg, 7+3*14, 4);
|
||||
|
||||
ic_body(ucg, 2, 10);
|
||||
|
||||
lower_pin(ucg, 7+0*14, 41);
|
||||
lower_pin(ucg, 7+1*14, 41);
|
||||
lower_pin(ucg, 7+2*14, 41);
|
||||
lower_pin(ucg, 7+3*14, 41);
|
||||
|
||||
ucg_SetColor(ucg, 0, 135*a/b, 206*a/b, 250*a/b);
|
||||
ucg_DrawString(ucg, 63+1, 33+1, 0, "glib");
|
||||
|
||||
ucg_SetColor(ucg, 0, 255, 168, 0);
|
||||
ucg_DrawGlyph(ucg, 26, 38, 0, 'U');
|
||||
ucg_DrawString(ucg, 63, 33, 0, "glib");
|
||||
|
||||
ucg_SetColor(ucg, 0, 135*a/b, 206*a/b, 250*a/b);
|
||||
ucg_SetColor(ucg, 1, 135*a/b, 206*a/b, 250*a/b);
|
||||
ucg_SetColor(ucg, 2, 135*a/b, 206*a/b, 250*a/b);
|
||||
ucg_SetColor(ucg, 3, 135*a/b, 206*a/b, 250*a/b);
|
||||
ucg_DrawGradientBox(ucg, 84+1, 42+1-6, 42, 4);
|
||||
|
||||
ucg_SetColor(ucg, 0, 255, 180, 40);
|
||||
ucg_SetColor(ucg, 1, 235, 148, 0);
|
||||
//ucg_DrawGradientLine(ucg, 79, 42, 20, 0);
|
||||
ucg_SetColor(ucg, 2, 245, 158, 0);
|
||||
ucg_SetColor(ucg, 3, 220, 138, 0);
|
||||
ucg_DrawGradientBox(ucg, 84, 42-6, 42, 4);
|
||||
|
||||
ucg_SetColor(ucg, 0, 255, 168, 0);
|
||||
//ucg_SetFont(ucg, ucg_font_5x8_tr);
|
||||
ucg_SetFont(ucg, ucg_font_7x13B_tr);
|
||||
//ucg_SetFont(ucg, ucg_font_courB08_tr);
|
||||
//ucg_SetFont(ucg, ucg_font_timR08_tr);
|
||||
ucg_DrawString(ucg, 2, 54+5, 0, "http://github.com");
|
||||
ucg_DrawString(ucg, 2, 61+10, 0, "/olikraus/ucglib");
|
||||
//ucg_DrawString(ucg, 1, 61, 0, "code.google.com/p/ucglib/");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
delay(1000);
|
||||
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
|
||||
ucg.clearScreen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
ucg.setRotate90();
|
||||
draw_ucg_logo(ucg.getUcg());
|
||||
for(;;)
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user