CircleHelper with GigaDisplay_GFX

Hi everyone

I am trying to use drawCircleHelper using GigaDisplay_GFX library, I dont know what to put in "corner name"........any help I will appreciate.

Regards

Hi @eljeancal28. The "GigaDisplay_GFX" library inherits its graphics functions from the "Adafruit GFX Library". You can see the documentation for the drawCircleHelper function here in that library's documentation:

https://adafruit.github.io/Adafruit-GFX-Library/html/class_adafruit___g_f_x.html#a3f2dd7b698e7b95ebf9fecf992ff802e

cornername Mask bit #1 or bit #2 to indicate which quarters of the circle we're doing

That description of the parameter is perhaps a bit cryptic. This is the result of each of the argument values:

  • 1: top left
  • 2: top right
  • 4: bottom right
  • 8: bottom left

Thanks a lot.

Hey
For some reason I cant open the link and the code dont work.
How do I write it?
topLeft or top_right, I did it both way and dont work.

Regards

You must use the number, not the words.

For example, if you wanted to draw a green 90 degree arc from the top right quadrant of a circle with radius of 100 centered on coordinate 240, 400, you would add something like this to your sketch:

tft.drawCircleHelper(240, 400, 100, 2, 0x07E0);

Thank you for your help but I am using GigaDisplay_GFX and not Adafruit, and it suppose to start with display.draw instead of tft.draw.

I already explained this in post #2. Please pay careful attention to what I write so that you can start progressing with your project again.

I'll provide a more detailed instruction in case what I wrote before wasn't clear enough: Just as you can use libraries in your sketch program, libraries can also use other libraries. Instead of reinventing the wheel, the developers of the "Arduino_GigaDisplay_GFX" library used (in technical terms "inherited") the existing excellent open source "Adafruit GFX Library" library for the abstract drawing capabilities. This meant that they only needed to implement the code needed to communicate the graphics data provided by "Adafruit GFX Library" to the GIGA Display Shield hardware.

In addition to helping the library developers, this approach of using an existing library helps the users because it means that you can use a standardized drawing API you might already be familiar with from using any of the other popular libraries for other display hardware (e.g., SSD1306) which also use the "Adafruit GFX Library".

The display or tft is an arbitrary object name you declare in the instantiation. This is why I wrote "something like this". I guessed you might have named it tft because I happened to be looking at the "Demo" example sketch of the library, which uses this name:

But I see now that other example code uses the name display.

Anyway, just use whatever object name you declared in your code.

1 Like

Thanks a lot, I appreciate :handshake:

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

Nope, it don't work, I did it exactly the same as you said but doesn't work.

It would be too much to ask you a screenshot of how you write the code for CircleHelper?

Screenshots are not an appropriate way to share code. Since code is text, we always share it as text.

I don't have a GIGA Display Shield on hand to test it out, but I believe this simple sketch should demonstrate the usage of the drawCircleHelper function:

#include <Arduino_GigaDisplay_GFX.h>

GigaDisplay_GFX display;

void setup() {
  display.begin();

  display.startWrite();
  display.drawCircleHelper(240, 400, 100, 2, 0x07E0);
  display.endWrite();
}

void loop() {}

The functions of the "Adafruit GFX Library" generally call the startWrite and endWrite functions for you. That is not done in the "helper" functions drawCircleHelper and fillCircleHelper because these function are used within other drawing functions (e.g., drawRoundRect). So you must call the startWrite and endWrite functions in your sketch code when using the "helper" functions.

Thanks a lot men, it is working now, my problem was that I was no using startWrite and endWrite.

The code I will text now is a code I find online and it is a code for a OLED display 128x64 and I am trying to modify the code using GigaDisplay_GFX for a Giga Display Shield and my friend I have almost one month trying to do it hehehehe, by the way, I am new coding, fresh experience, thanks again.

Here is the code:

/*

Analog gauge v1.02

  • Shows half circle gauge with scale labels

  • Shows digital value, 00 - 100 aligned

  • Shows gauge label

21/12/2015 - Rudi Imbrechts

http://arduinows.blogspot.com

*/

#include "U8glib.h"

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Res = 12

                                            // For OLED display with SH1106 driver. If you use another display,

                                            // then please check the u8glib documentation and website at

                                            // https://github.com/olikraus/u8glib

int xmax=128; // max length x-axis

int ymax=62; // max length y-axis

int xcenter=xmax/2; // center of x-axis

int ycenter=ymax/2+10; // center of y-axis

int arc=ymax/2;

int angle=0;

char* label[] = {"LOAD","COOLANT","INTAKE", "VOLT"}; // some custom gauge labels

int labelXpos[] = {53, 45, 49, 53}; // predefined x-position of a gauge label

#define potmeterPin A1 // simulate analogue value with potentiometer

int p, w, m,a=10;

u8g_uint_t xx=0;

// ------------------------------------------------- void gauge() ------------------------------------------

void gauge(uint8_t angle) {

// draw border of the gauge

u8g.drawCircle(xcenter,ycenter,arc+6, U8G_DRAW_UPPER_RIGHT);

u8g.drawCircle(xcenter,ycenter,arc+4, U8G_DRAW_UPPER_RIGHT);

u8g.drawCircle(xcenter,ycenter,arc+6, U8G_DRAW_UPPER_LEFT);

u8g.drawCircle(xcenter,ycenter,arc+4, U8G_DRAW_UPPER_LEFT);

// draw the needle

float x1=sin(2angle2*3.14/360); // needle position

float y1=cos(2angle2*3.14/360);

u8g.drawLine(xcenter, ycenter, xcenter+arcx1, ycenter-arcy1);

u8g.drawDisc(xcenter, ycenter, 5, U8G_DRAW_UPPER_LEFT);

u8g.drawDisc(xcenter, ycenter, 5, U8G_DRAW_UPPER_RIGHT);

u8g.setFont(u8g_font_chikita);

// show scale labels

u8g.drawStr( 20, 42, "0");

u8g.drawStr( 25, 18, "25");

u8g.drawStr( 60, 14, "50");

u8g.drawStr( 95, 18, "75");

u8g.drawStr( 105, 42, "100");

// show gauge label

u8g.setPrintPos(labelXpos[0],32);

u8g.print(label[0]);

// show digital value and align its position

u8g.setFont(u8g_font_profont22);

u8g.setPrintPos(54,60);

if (w<10){ // leading 0 when value less than 10

u8g.print("0");

}

if (w>99) { // position at 100%

u8g.setPrintPos(47,60);

}

u8g.print(w);

}

// ------------------------------------------------- void setup() ------------------------------------------

void setup(void) {

u8g.setFont(u8g_font_chikita);

u8g.setColorIndex(1); // Instructs the display to draw with a pixel on.

// assign default color value

if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {

u8g.setColorIndex(255);                     // white

}

else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {

u8g.setColorIndex(3);                       // max intensity

}

else if ( u8g.getMode() == U8G_MODE_BW ) {

u8g.setColorIndex(1);                       // pixel on

}

else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {

u8g.setHiColorByRGB(255,255,255);

}

}

// ------------------------------------------------- void loop() ------------------------------------------

void loop(void) {

p = analogRead(A0);

w = map(p,0,1023,0,100); // map it between 0 and 100

m = map(p,0,1023,0,90); // map needle movement

// show needle and dial

xx = m; // 135 = zero position, 180 = just before middle, 0 = middle, 45 = max

if (xx<45){ // positie correctie

xx=xx+135;

}

else {

xx=xx-45;

}

// picture loop

{

u8g.firstPage(); 

do {             

  gauge(xx);

}

while( u8g.nextPage() );

}

}

You are welcome. I'm glad it is working now.

Regards,
Per

:handshake: :handshake: :handshake: