Ciao, ho provato a utilizzare un display grafico 128x64 "cinese" il modello è cmbg12864J-02 Ver.A03.
dopo ore e ore al pc, ho visto che il controllore che monta dovrebbe essere un un nt7108, nel codice che ho utilizzato (seguendo il primo video che appare se cerchi gldc arduino su yt), dice di togliere il commento sul modello di display che si usa, non trovando nè quello nè quello del video ho cercato degli equivalenti al nt7108 e ho visto il ks 0108.
una volta decommentato la linea di codice che indicava quel controllore di glcd ho verificato il codice, funziona tutto; carico il codice: il display si accende, ma non mostra nessuna immagine o animazione. su internet dicono di girare il trimmer nel retro del display, ma nel mio non c'è nessun trimmer, c'è un pezzo di scheda, in cui probabilmente andava un componente, in cui c'è scritto "VR", e ha tre punti in cui stagnare.
il codice è quello degli esempi della libreria u8g2, comunque lo scrivo adesso qui sotto:
/*
GraphicsTest.ino
Some graphics/text output for U8x8 API
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
Copyright (c) 2016, 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.
*/
#include <Arduino.h>
#include <U8x8lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
// Please UNCOMMENT one of the contructor lines below
// U8x8 Contructor List
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp
// Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected
//U8X8_NULL u8x8; // null device, a 8x8 pixel display which does nothing
U8X8_KS0108_ERM19264 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low!
// End of constructor list
/*
This example will probably not work with the SSD1606, because of the
iernal buffer swapping
*/
void setup(void)
{
/* U8g2 Project: 0108 Test Board */
//pinMode(16, OUTPUT);
//digitalWrite(16, 0);
/* U8g2 Project: Pax Instruments Shield: Enable Backlight */
//pinMode(6, OUTPUT);
//digitalWrite(6, 0);
u8x8.begin();
//u8x8.setFlipMode(1);
}
void pre(void)
{
u8x8.setFont(u8x8_font_amstrad_cpc_extended_f);
u8x8.clear();
u8x8.inverse();
u8x8.print(" U8x8 Library ");
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.noInverse();
u8x8.setCursor(0,1);
}
void draw_bar(uint8_t c, uint8_t is_inverse)
{
uint8_t r;
u8x8.setInverseFont(is_inverse);
for( r = 0; r < u8x8.getRows(); r++ )
{
u8x8.setCursor(c, r);
u8x8.print(" ");
}
}
void draw_ascii_row(uint8_t r, int start)
{
int a;
uint8_t c;
for( c = 0; c < u8x8.getCols(); c++ )
{
u8x8.setCursor(c,r);
a = start + c;
if ( a <= 255 )
u8x8.write(a);
}
}
void loop(void)
{
int i;
uint8_t c, r, d;
pre();
u8x8.print("github.com/");
u8x8.setCursor(0,2);
u8x8.print("olikraus/u8g2");
delay(2000);
u8x8.setCursor(0,3);
u8x8.print("Tile size:");
u8x8.print((int)u8x8.getCols());
u8x8.print("x");
u8x8.print((int)u8x8.getRows());
delay(2000);
pre();
for( i = 19; i > 0; i-- )
{
u8x8.setCursor(3,2);
u8x8.print(i);
u8x8.print(" ");
delay(150);
}
draw_bar(0, 1);
for( c = 1; c < u8x8.getCols(); c++ )
{
draw_bar(c, 1);
draw_bar(c-1, 0);
delay(50);
}
draw_bar(u8x8.getCols()-1, 0);
pre();
u8x8.setFont(u8x8_font_amstrad_cpc_extended_f);
for( d = 0; d < 8; d ++ )
{
for( r = 1; r < u8x8.getRows(); r++ )
{
draw_ascii_row(r, (r-1+d)*u8x8.getCols() + 32);
}
delay(400);
}
draw_bar(u8x8.getCols()-1, 1);
for( c = u8x8.getCols()-1; c > 0; c--)
{
draw_bar(c-1, 1);
draw_bar(c, 0);
delay(50);
}
draw_bar(0, 0);
pre();
u8x8.drawString(0, 2, "Small");
u8x8.draw2x2String(0, 5, "Scale Up");
delay(3000);
pre();
u8x8.drawString(0, 2, "Small");
u8x8.setFont(u8x8_font_px437wyse700b_2x2_r);
u8x8.drawString(0, 5, "2x2 Font");
delay(3000);
pre();
u8x8.drawString(0, 1, "3x6 Font");
u8x8.setFont(u8x8_font_inb33_3x6_n);
for(i = 0; i < 100; i++ )
{
u8x8.setCursor(0, 2);
u8x8.print(i); // Arduino Print function
delay(10);
}
for(i = 0; i < 100; i++ )
{
u8x8.drawString(0, 2, u8x8_u16toa(i, 5)); // U8g2 Build-In functions
delay(10);
}
pre();
u8x8.drawString(0, 2, "Weather");
u8x8.setFont(u8x8_font_open_iconic_weather_4x4);
for(c = 0; c < 6; c++ )
{
u8x8.drawGlyph(0, 4, '@'+c);
delay(300);
}
pre();
u8x8.print("print \\n\n");
delay(500);
u8x8.println("println");
delay(500);
u8x8.println("done");
delay(1500);
pre();
u8x8.fillDisplay();
for( r = 0; r < u8x8.getRows(); r++ )
{
u8x8.clearLine(r);
delay(100);
}
delay(1000);
}