Exemple #1
0
void aurora_cpt_oled::init()
{
	oled1.begin(SSD1306_SWITCHCAPVCC, 0x3C);
	oled1.clearDisplay();   // clears the screen and buffer
	oled1.display();
	oled1.setTextSize(1);
	oled1.setTextColor(WHITE);
}
Exemple #2
0
void testfillrect(void) {
  uint8_t color = 1;
  for (int16_t i=0; i<display.height()/2; i+=3) {
    // alternate colors
    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
    display.display();
    color++;
  }
}
Exemple #3
0
void menus::drawListItem(String text, byte index) {            //draws a list item, needs it's position/index
    if(activeItem == index) {
        display.setTextColor(BLACK, WHITE);
    }
    else {
        display.setTextColor(WHITE);
    }
    display.setTextSize(1);
    display.println(text);
}
void Demo1()
{
	Serial.println("Display: circle");
	// Clear the buffer.
	display.clearDisplay();
	// draw a circle, 10 pixel radius
	display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
	display.display();
	DemoTimer.stop();
	DemoTimer.initializeMs(2000, Demo2).start();	
}
Exemple #5
0
void testdrawchar(void) {
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);

  for (uint8_t i=0; i < 168; i++) {
    if (i == '\n') continue;
    display.write(i);
    //if ((i > 0) && (i % 14 == 0))
      //display.println();
  }
  display.display();
}
void MyDisplay::begin()
{
    byte error;

    Wire.lock();

#if DISPLAY_TYPE == DISPLAY_TYPE_SSD1306
    Wire.beginTransmission(0x3c);
    error = Wire.endTransmission();

    if (error == 0)
    {
        displayFound = TRUE;
        Debug.printf("Found OLED at %x\n", 0x3c);
        // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)`
        // initialize with the I2C addr 0x3D (for the 128x64)
        // bool:reset set to TRUE or FALSE depending on you display
        display.begin(SSD1306_SWITCHCAPVCC, SSD1306_I2C_ADDRESS, FALSE);
        // display.begin(SSD1306_SWITCHCAPVCC);
        display.display();
    }
#elif DISPLAY_TYPE == DISPLAY_TYPE_20X4
    Wire.beginTransmission(I2C_LCD_ADDR);
    error = Wire.endTransmission();

    if (error == 0)
    {
        displayFound = TRUE;
        Debug.printf("Found LCD at %x\n", I2C_LCD_ADDR);
        lcd.begin(20, 4);
        lcd.setCursor(0, 0);
        lcd.print((char *)"MySensors gateway   ");
    }
    else
    {
        Debug.printf("LCD not found at %x\n", I2C_LCD_ADDR);
    }        
#else
    Debug.println("No display available");
    error = 0xff;
#endif

    Wire.unlock();

    if (displayFound)
    {
        displayTimer.initializeMs(1000, TimerDelegate(&MyDisplay::update, this)).start(true);
    }
}
Exemple #7
0
void testdrawtriangle(void) {
  for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
    display.drawTriangle(display.width()/2, display.height()/2-i,
                     display.width()/2-i, display.height()/2+i,
                     display.width()/2+i, display.height()/2+i, WHITE);
    display.display();
  }
}
Exemple #8
0
void menus::drawList() {            //used to draw the list of items, and highlight the currently selected one
    display.setCursor(0, 10);
    drawListItem(mTime.getTitle(), 0);
    drawListItem("Reserved", 1);
    drawListItem("About", 2);
    drawListItem("Return", 3);
}
void init()
{
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(true); // Debug output to serial

	display.begin(SSD1306_SWITCHCAPVCC);
	display.clearDisplay();

	dht.begin();

	WifiStation.config(WIFI_SSID, WIFI_PWD);
	WifiStation.enable(true);
	WifiAccessPoint.enable(false);

	// Run our method when station was connected to AP (or not connected)
	WifiStation.waitConnection(connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start
}
Exemple #10
0
void testfilltriangle(void) {
  uint8_t color = BLACK;
  for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
    display.fillTriangle(display.width()/2, display.height()/2-i,
                     display.width()/2-i, display.height()/2+i,
                     display.width()/2+i, display.height()/2+i, color);
    if (color == WHITE) color = BLACK;
    else color = WHITE;
    display.display();
  }
}
void init()
{
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(true); // Allow debug output to serial

	// Initialize display and sensor
	display.begin(SSD1306_SWITCHCAPVCC);
	display.display();
	
	// Wifi could be used eg. for display info from internet
	// could be also dissabled if no needed
	WifiStation.config(WIFI_SSID, WIFI_PWD);
	WifiStation.enable(true);
	WifiAccessPoint.enable(false);
	WifiStation.waitConnection(connect_Ok, 20, connect_Fail);

	// Start timer
	DemoTimer.initializeMs(2000, Demo1).start();
}	
Exemple #12
0
void menus::doMain() {
    if(showMenu) {
        doItem();
    }
    else {
        disp.drawBtnBar('^', "Select", 'v');
        disp.showTitle("Main Menu");
        drawList();
    }
    display.display();
}
Exemple #13
0
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
  uint8_t icons[NUMFLAKES][3];

  // initialize
  for (uint8_t f=0; f< NUMFLAKES; f++) {
    icons[f][XPOS] = rand()%display.width();
    icons[f][YPOS] = 0;
    icons[f][DELTAY] = rand()%(5) + 1;
  }

  while (1) {
    // draw each icon
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
    }
    display.display();
    delay(20);

    // then erase it + move it
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      display.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, BLACK);
      // move it
      icons[f][YPOS] += icons[f][DELTAY];
      // if its gone, reinit
      if (icons[f][YPOS] > display.height()) {
	icons[f][XPOS] = rand()%(display.width());
	icons[f][YPOS] = 0;
	icons[f][DELTAY] = rand()%(5) + 1;
      }
    }
   }
}
Exemple #14
0
void Demos::CK_logo(Adafruit_SSD1306& d)
{
	#define K 1024  // wave																		// scale ofs
	#define CX(x) {  x = w-cx;  x = ( (x*(K +ax*Cos(8*w      +tt[0])/SY*Sin(7*w      +tt[1])/SY) /K) +cx)/8 +6;  }
	#define CY(y) {  y = w-cy;  y = ( (y*(K +ay*Cos(9*w+ x*73+tt[2])/SY*Sin(6*w+ x*52+tt[3])/SY) /K) +cy)/9 -1;  }

	const uint tt[4] = {t*7,t*5,t*8,t*5};
	for (int w2=0; w2<2; ++w2)
	{
		const int cx = cw[ckCur][w2], cy = cw[ckCur][2+w2],
				ax = cw[ckCur][4+w2], ay = cw[ckCur][6+w2];
		int a=0,w, i=0,rst=1,
			x1=0,y1=0,x=0,y=0;
		do
		{	w = w2 ? word2[a++] : word1[a++];
			if (w<=0) {  rst=1;  i=0;  }
			else
			if (rst)  switch(i)
			{	case 0:  CX(x)  ++i;  break;
				case 1:  CY(y)  rst=0; i=0;  break;  }
			else  switch(i)
			{	case 0:  x1=x;  CX(x)  ++i;  break;
				case 1:  y1=y;  CY(y)  i=2;  break;  }

			if (i==2)
			{	i=0;  d.drawLine(x1,y1, x,y, WHITE);  }
		}
		while (w >= 0);
	}

	if (iInfo > 0)
	{
		d.setCursor(0,8);
		d.print("Cur ");  d.println(ckCur);
		d.print("Spd ");  d.println(ckSpeed);
	}

	t += ckSpeed;
	delay(6);
}
Exemple #15
0
/**
   Popup input window with text centered. Window height is based on maxChars
*/
void ANXInputWindow(char * message, char *title, uint8_t maxChars) {

  uint8_t w = (display.width() * .8) + 4;
  uint8_t maxCharsPerRow = w / ANX_FONT_WIDTH;
  uint8_t rows = (maxChars / maxCharsPerRow) + 1;
  uint8_t textHeight = rows * ANX_FONT_HEIGHT;
  uint8_t h = textHeight + ANX_FONT_HEIGHT + 3 + 2;
  uint8_t x = (display.width() - w) / 2;
  uint8_t y = (display.height() - h) / 2;
  uint8_t tx = (display.width() - (ANX_FONT_WIDTH * strlen(title))) / 2;
  uint8_t ty = y + 1;

  display.fillRoundRect(x, y, w, h, 2, BLACK);
  display.drawRoundRect(x, y, w, h, 2, WHITE);
  display.fillRoundRect(x, y, w, ANX_FONT_HEIGHT + 1, 2, WHITE);

  display.setCursor(tx, ty);
  display.setTextColor(INVERSE);
  display.print(title);

  ANXInput(message, x + 2, y + ANX_FONT_HEIGHT + 3, maxChars, maxCharsPerRow);
}
void displayText(String s_msg) {
	display.fillRect(0, 32, 128, 32, BLACK);
	display.setTextSize(1);
	display.setTextColor(WHITE);
	display.setCursor(5,40);
	display.println(s_msg);
	display.display();
}
void displayTemp(String s_temp) {
	display.fillRect(0, 0, 128, 32, BLACK);
	display.setTextSize(1);
	display.setTextColor(WHITE);
	display.setCursor(5,10);
	display.println(s_temp);
	display.display();
}
Exemple #18
0
void testfillroundrect(void) {
  uint8_t color = BLACK;
  for (int16_t i=0; i<display.height()/2-2; i+=2) {
    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
    if (color == WHITE) color = BLACK;
    else color = WHITE;
    display.display();
  }
}
Exemple #19
0
void testdrawcircle(void) {
  for (int16_t i=0; i<display.height(); i+=2) {
    display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
    display.display();
  }
}
Exemple #20
0
///  Draw 3D
void Demos::Hedrons(Adafruit_SSD1306& d)
{
	if (hdtOn)
	{	++hdt;
		if (hdt >= hdtMax)
		{	hdt = 0;  ++hdCur;  // next type
			if (hdCur >= hdA)  hdCur = 0;
	}	}
	const int u = hdCur;

	const float SC = SCa[u];  // scale
	float rx=0.f,ry=0.f,rz=0.f, s = SC, ss=1.f;
	switch (hdRot)  //par rot speed
	{	case 0:  rx = t*0.0055f;  ry = t*0.0065f;  rz = t*0.0075f;  break;
		case 1:  rx = t*0.0061f;  ry = t*0.0084f;  rz = t*0.0077f;  break;
		case 2:  rx = t*0.0067f;  ry = t*0.0098f;  rz = t*0.0083f;
			ss = 1.0f - 0.4f * (abs(cos(t*0.0125f)));  break;
		case 3:  ry = t*0.0060f;  rz = t*0.0020f;  break;
	}

	const int NP = NPa[u], NE = NEa[u], NF = NFa[u];
	const float* pp = ppA[u];
	const uint8_t* ee = eeA[u], *ff = ffA[u];

	const float  ///par  z pos  screen scale
		fovy = 30.f, zz = 3.f, se = 2.f,
		fv = 1.f/tan(fovy*0.5f),  // const
		cx = cos(rx), sx = sin(rx), cy = cos(ry), sy = sin(ry),
		cz = cos(rz), sz = sin(rz),
		mx[3][3] = {{1.f,0.f,0.f},{0.f,cx,-sx},{0.f,sx,cx}},  // rot x
		my[3][3] = {{cy,0.f,sy},{0.f,1.f,0.f},{-sy,0.f,cy}},  // y
		mz[3][3] = {{cz,-sz,0.f},{sz,cz,0.f},{0.f,0.f,1.f}};  // z


	//  transform all points
	int16_t px[NP], py[NP];  int8_t c[NP];
	int i, a;
	for (i=0,a=0; i < NP; ++i)
	{
		float x = pp[a++], y = pp[a++], z = pp[a++];
		float v[3];
		v[0] = mx[0][0]*x +mx[0][1]*y +mx[0][2]*z;  // rotate
		v[1] = mx[1][0]*x +mx[1][1]*y +mx[1][2]*z;
		v[2] = mx[2][0]*x +mx[2][1]*y +mx[2][2]*z;
		x = v[0];  y = v[1];  z = v[2];
		v[0] = my[0][0]*x +my[0][1]*y +my[0][2]*z;
		v[1] = my[1][0]*x +my[1][1]*y +my[1][2]*z;
		v[2] = my[2][0]*x +my[2][1]*y +my[2][2]*z;
		x = v[0];  y = v[1];  z = v[2];
		v[0] = mz[0][0]*x +mz[0][1]*y +mz[0][2]*z;
		v[1] = mz[1][0]*x +mz[1][1]*y +mz[1][2]*z;
		v[2] = mz[2][0]*x +mz[2][1]*y +mz[2][2]*z;
		x = v[0] * s;  y = v[1] * s;  z = v[2] * s + ss*zz;

		px[i] = H/2 * se * (fv * x / -z) +W/2;  // pos 3d to 2d
		py[i] = H/2 * se * (fv * y / -z) +H/2;

		c[i] = z < 0.9f ? -1 : (z < zz ? 1 : 0);
		if (px[i]<0 || px[i]>=W || py[i]<0 || py[i]>=H)
			c[i] = -1;  // outside
		//c[i] = z < zz ? 1 : 0;
		//d.drawPixel(px[i], py[i],WHITE);
	}
	
	//  draw far/covered edges  --
	for (i=0,a=0; i < NE; ++i)
	{
		int e0 = ee[a++], e1 = ee[a++];
		int8_t cc = max(c[e0],c[e1]);
		if (cc==0)
			d.drawLine( px[e0],py[e0], px[e1],py[e1], WHITE);
	}

	//  draw far faces  /|
	if (ff)
	for (i=0,a=0; i < NF; ++i)
	{
		int f0 = ff[a++], f1 = ff[a++], f2 = ff[a++];
		int8_t cc = min(c[f0],c[f1]);  cc = min(cc,c[f2]);
		if (cc==0)
			d.fillTriangle( px[f0],py[f0], px[f1],py[f1], px[f2],py[f2], WHITE);
	}

	//  dither 2 full screen  --------
	uint8_t* buf = d.getBuffer();
	for (i=0; i < W*H/8; i+=2)  buf[i] &= 0xAA;
	for (i=1; i < W*H/8; i+=2)  buf[i] &= 0x55;

	//  draw near/visible edges  --
	for (i=0,a=0; i < NE; ++i)
	{
		int e0 = ee[a++], e1 = ee[a++];
		int8_t cc = max(c[e0],c[e1]);
		if (cc>0)
			d.drawLine( px[e0],py[e0], px[e1],py[e1], WHITE);
	}
	
	//  draw near faces  /|
	if (ff)
	for (i=0,a=0; i < NF; ++i)
	{
		int f0 = ff[a++], f1 = ff[a++], f2 = ff[a++];
		int8_t cc = min(c[f0],c[f1]);  cc = min(cc,c[f2]);
		if (cc>0)
			d.fillTriangle( px[f0],py[f0], px[f1],py[f1], px[f2],py[f2], WHITE);
	}

	if (iInfo > 0)
	{
		d.setCursor(0,8);
		d.print("Cur ");  d.println(hdCur);
		d.print("Rot ");  d.println(hdRot);
		if (hdtOn)  d.println("On");
	}
	++t;
	delay(8);
}
Exemple #21
0
void MyDisplay::update()
{
    Wire.lock();

#if DISPLAY_TYPE == DISPLAY_TYPE_SSD1306
    display.clearDisplay();
    // text display tests
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("MySensors gateway");
    display.setTextSize(1);
    display.setCursor(0,9);
    if (AppSettings.wired)
    {
        if (!Network.getClientIP().isNull())
        {
            display.print("IP  :");
            display.println(Network.getClientIP().toString());
        } 
        else
        {
            display.setTextColor(BLACK, WHITE); // 'inverted' text
            display.println("connecting ...");
            display.setTextColor(WHITE);
        }
    }
    else
    {
        if (WifiStation.isConnected())
        {
            display.print("AP  :");
            display.println(Network.getClientIP().toString());
        } 
        else
        {
            display.setTextColor(BLACK, WHITE); // 'inverted' text
            display.println("connecting ...");
            display.setTextColor(WHITE);
        }
    }
    display.setCursor(0,18);
    if (isMqttConfigured())
    {
        display.print("MQTT:");
        display.println(MqttServer());
    }
    else
    {
        display.setTextColor(BLACK, WHITE); // 'inverted' text
        display.println("configure MQTT !");
        display.setTextColor(WHITE);
    }

    display.setCursor(0,27);
    display.println(SystemClock.getSystemTimeString().c_str());
    display.setCursor(0,36);
    display.print("HEAP :");
    display.setTextColor(BLACK, WHITE); // 'inverted' text
    display.println(system_get_free_heap_size());

    display.setTextColor(WHITE);

    //display.setTextColor(BLACK, WHITE); // 'inverted' text
    //display.setTextSize(3);
    display.display();
#elif DISPLAY_TYPE == DISPLAY_TYPE_20X4
    lcd.setCursor(0, 0);
    lcd.print((char *)"MySensors gateway   ");
    lcd.setCursor(0, 1);
    lcd.print((char *)build_git_sha);
    for (int i=0; i<(20-strlen((char *)build_git_sha)); i++)
        lcd.print(" ");
    lcd.setCursor(0, 2);
    lcd.print("HEAP :");
    String heap(system_get_free_heap_size());
    lcd.print(heap.c_str());
    for (int i=0; i<20-6-heap.length(); i++)
        lcd.print(" ");
    lcd.setCursor(0, 3);
    lcd.print("IP   :");
    String ip = Network.getClientIP().toString();
    lcd.print(ip.c_str());
    for (int i=0; i<20-6-ip.length(); i++)
        lcd.print(" ");
#endif

    Wire.unlock();
}
Exemple #22
0
int main(int argc, char **argv)
{
  float soil = 65.5;
  float temp = 5.5;

	// I2C change parameters to fit to your LCD
	if ( !display.init(OLED_I2C_RESET,OLED_ADAFRUIT_I2C_128x64) )
		exit(EXIT_FAILURE);

	display.begin();
	
	// init done
	display.clearDisplay();   // clears the screen and buffer

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("     XBee Messung\n");
  display.drawLine(0, 10, display.width()-1, 10, WHITE);
  display.setCursor(0,15);
  display.printf("Bodenfeuchte: %4.1f %%\n", soil);
  display.printf("Temperatur:   %4.1f C\n\n\n", temp);
  if(soil > 50) {
    display.print("--> Feucht genug\n");
  } else {
    display.print("--> Zu Trocken! \n");
  }
  
  display.display();

  // Free PI GPIO ports
  display.close();
}
void Demo2()
{
	Serial.println("Display: some text");
	display.clearDisplay();
	// text display tests
	display.setTextSize(1);
	display.setTextColor(WHITE);
	display.setCursor(0,0);
	display.println("Sming Framework");
	display.setTextColor(BLACK, WHITE); // 'inverted' text
	display.setCursor(104, 7);
	display.println("v1.0");
	//----
	display.setTextColor(WHITE);
	display.println("Let's do smart things");
	display.setTextSize(3);
	display.print("IoT");
	display.display();
	DemoTimer.stop();      // Finish demo
}
Exemple #24
0
void doChat() {
  //Setup chat
  _maxCharsPerRow = (display.width() / ANX_FONT_WIDTH) - 2;
  _bottom = CHAT_MESSAGES_MAX - 1;

  uint8_t button = 0;
  uint8_t lastChatPtr = 0;
  bool quit = false;

  //Warn user then quit if radio is not available
  if (!ANXRFAvailable()) {
    statusDialog("Radio disabled");
    quit = true;
  }

  //Warn user then quit if in airplane mode
  if (ANXGetAirplane()) {
    statusDialog("Badge is in\nairplane mode");
    quit = true;
  }

  if (quit) {
    waitForButton();
    clearButtonState();
    return;
  }

  while (1) {
    _drawMessages();
    lastChatPtr = chatBufferPtr;

    //Idle handling RF and buttons
    while (chatBufferPtr == lastChatPtr && button == 0) {
      //Handle tasks
      tick();
      //Check buttons
      button = getButtonState();
    }

    //Handle button presses in one block
    //If message is null, meaning nothing was passed into doChat, then execute a normal chat entry.
    if (button > 0) {
      //Quit on left
      if (button == BUTTON_LEFT) {
        clearButtonState();
        return;
      }

      //Popup chat window on enter
      if (button == BUTTON_ENTER) {
        clearButtonState();

        //Get a
        char message[ANX_CHAT_MAX_LENGTH];
        memset(message, '\0', ANX_CHAT_MAX_LENGTH); //initialize to null before using no matter wut
        ANXInputWindow(message, mi_main_chat, ANX_CHAT_MAX_LENGTH);
        if (strlen(message) > 0) {
          ANXRFSendChat(message);
        }
      }
    }
    //cleanup
    button = 0;
  }
}
Exemple #25
0
void _drawMessages() {
  //Move the cursor to the bottom of the screen
  display.setCursor(0, display.height());
  display.setTextWrap(true);
  int8_t row = _bottom;

  display.clearDisplay();

  //If first message is blank quit
  ChatMessage first = getFromChatBuffer(_bottom);
  if (strlen(first.name) == 0) {
    display.setCursor(1, 1);
    display.print("Nothing's here");
    safeDisplay();
    return;
  }

  //Draw each message starting from the bottom of the screen
  while (display.getCursorY() >= 0 && row >= 0) {
    ChatMessage message = getFromChatBuffer(row);

    //Stop drawing messages if we hit an empty one
    if (strlen(message.message) == 0 && strlen(message.name) == 0) {
      break;
    }

    //Determine if the the mesage is two line or not
    bool twoLine = (strlen(message.name) + strlen(message.message) > _maxCharsPerRow);

    //Move cursor up to print the line(s)
    uint8_t y = display.getCursorY() - ANX_FONT_HEIGHT;
    if (twoLine) {
      y -= ANX_FONT_HEIGHT;
    }
    display.setCursor(0, y);

    //Ensure username is null terminated
    char name[USERNAME_MAX_LENGTH + 1];
    memcpy(name, message.name, USERNAME_MAX_LENGTH);
    name[USERNAME_MAX_LENGTH] = '\0';

    //Ensure message is null terminated
    char msg[ANX_CHAT_MAX_LENGTH + 1];
    memcpy(msg, message.message, ANX_CHAT_MAX_LENGTH);
    msg[ANX_CHAT_MAX_LENGTH] = '\0';

    display.print("@");
    display.print(name);
    display.print(":");
    display.println(msg);

    //Move cursor back up above the message we just printed
    display.setCursor(0, y);

    row--;
  }

  //Show
  safeDisplay();
}
Exemple #26
0
int main()
{
	int i, j;
	int black = 1;
	display.init(PIN_DC, PIN_RESET, PIN_CS, OLED_ADAFRUIT_SPI_128x32);
	display.begin();

	/* 左上 */
	display.drawPixel(0, 0, WHITE);
	display.display();
	sleep(2);

	/* 左下 */
	display.drawPixel(0, 31, WHITE);
	display.display();
	sleep(2);

	/* 右上 */	
	display.drawPixel(127, 0, WHITE);
	display.display();
	sleep(2);

	/* 右下 */
        display.drawPixel(127, 31, WHITE);
        display.display();
        sleep(2);

	for (i = 0; i < 32; i++) {
		for (j = 0; j < 128; j++) {
			//display.drawPixel(j, i, (black % 2) ? BLACK : WHITE);
			display.drawPixel(j, i, WHITE);
			display.display();
			black++;
		}
		//black = i;
		//display.display();
	}

	display.clearDisplay();
	display.close();
	return 0;
}
Exemple #27
0
void testdrawrect(void) {
  for (int16_t i=0; i<display.height()/2; i+=2) {
    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
    display.display();
  }
}
Exemple #28
0
void testdrawline() {
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(0, 0, i, display.height()-1, WHITE);
    display.display();
  }
  for (int16_t i=0; i<display.height(); i+=4) {
    display.drawLine(0, 0, display.width()-1, i, WHITE);
    display.display();
  }
  delay(25);

  display.clearDisplay();
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(0, display.height()-1, i, 0, WHITE);
    display.display();
  }
  for (int8_t i=display.height()-1; i>=0; i-=4) {
    display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
    display.display();
  }
  delay(25);

  display.clearDisplay();
  for (int16_t i=display.width()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
    display.display();
  }
  for (int16_t i=display.height()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
    display.display();
  }
  delay(25);

  display.clearDisplay();
  for (int16_t i=0; i<display.height(); i+=4) {
    display.drawLine(display.width()-1, 0, 0, i, WHITE);
    display.display();
  }
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
    display.display();
  }
  delay(25);
}
Exemple #29
0
void testscrolltext(void) {
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(10,0);
  display.clearDisplay();
  display.println((char*)"scroll");
  display.display();

  display.startscrollright(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrollleft(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrolldiagright(0x00, 0x07);
  delay(2000);
  display.startscrolldiagleft(0x00, 0x07);
  delay(2000);
  display.stopscroll();
}
Exemple #30
0
void test_task(void*)   {
	while(1){
		display.begin();
		//display.setContrast(50);
		display.display();

		delay(2000);
		display.clearDisplay();   // clears the screen and buffer

		// draw a single pixel
		display.drawPixel(10, 10, WHITE);
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw many lines
		testdrawline();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw rectangles
		testdrawrect();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw multiple rectangles
		testfillrect();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw mulitple circles
		testdrawcircle();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw a circle, 10 pixel radius
		display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
		display.display();
		delay(2000);
		display.clearDisplay();

		testdrawroundrect();
		delay(2000);
		display.clearDisplay();

		testfillroundrect();
		delay(2000);
		display.clearDisplay();

		testdrawtriangle();
		delay(2000);
		display.clearDisplay();

		testfilltriangle();
		delay(2000);
		display.clearDisplay();

		// draw the first ~12 characters in the font
		testdrawchar();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw scrolling text
		testscrolltext();
		delay(2000);
		display.clearDisplay();

		// text display tests
		display.setTextSize(2);
		display.setTextColor(WHITE);
		display.setCursor(0,0);
		display.println((char*)"Hello, world!");
		display.setTextColor(WHITE, BLACK); // 'inverted' text
		display.println((char*)"3.141592");
		display.setTextSize(1);
		display.setTextColor(WHITE);
		display.print((char*)"0x");
		display.println((char*)"DEADBEEF");
		display.display();
		delay(2000);

		// rotation example
		display.clearDisplay();
		display.setRotation(1);  // rotate 90 degrees counter clockwise, can also use values of 2 and 3 to go further.
		display.setTextSize(1);
		display.setTextColor(WHITE);
		display.setCursor(0,0);
		display.println((char*)"Rotation");
		display.setTextSize(1);
		display.println((char*)"Example!");
		display.display();
		delay(2000);

		// revert back to no rotation
		display.setRotation(0);

		// miniature bitmap display
		display.clearDisplay();
		display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, WHITE);
		display.display();

		// invert the display
		display.invertDisplay(true);
		delay(1000);
		display.invertDisplay(false);
		delay(1000);

		// draw a bitmap icon and 'animate' movement
		testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT);
	}
}