Error rwreg does not name a type

hi can anyone help,i am getting error in compling the example graphictest. using stm32 bluepill 64k ILI9488.h:186:14: error: 'RwReg' does not name a type 186 | volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport; | ^~~~~ exit s...

hi
can anyone help,i am getting error in compling the example graphictest. using stm32 bluepill 64k

ILI9488.h:186:14: error: ‘RwReg’ does not name a type
186 | volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
| ^~~~~
exit status 1
Error compiling for board Generic STM32F1 series

posting file below ILI9488.h

/***************************************************
STM32 Support added by Jaret Burkett at OSHlab.com

This is our library for the Adafruit ILI9488 Breakout and Shield
—-> http://www.adafruit.com/products/1651

Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/

#ifndef ILI9488H
#define ILI9488H

#if ARDUINO >= 100
#include «Arduino.h»
#include «Print.h»
#else
#include «WProgram.h»
#endif
#include <Adafruit_GFX.h>
#ifdef __AVR
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#endif

#ifdef ARDUINO_STM32_FEATHER
typedef volatile uint32 RwReg;
#endif
#if defined (AVR) || defined(TEENSYDUINO) || defined (arm) || defined (STM32F1)

#define USE_FAST_PINIO
#endif

#define ILI9488_TFTWIDTH 320
#define ILI9488_TFTHEIGHT 480

#define ILI9488_NOP 0x00
#define ILI9488_SWRESET 0x01
#define ILI9488_RDDID 0x04
#define ILI9488_RDDST 0x09

#define ILI9488_SLPIN 0x10
#define ILI9488_SLPOUT 0x11
#define ILI9488_PTLON 0x12
#define ILI9488_NORON 0x13

#define ILI9488_RDMODE 0x0A
#define ILI9488_RDMADCTL 0x0B
#define ILI9488_RDPIXFMT 0x0C
#define ILI9488_RDIMGFMT 0x0D
#define ILI9488_RDSELFDIAG 0x0F

#define ILI9488_INVOFF 0x20
#define ILI9488_INVON 0x21
#define ILI9488_GAMMASET 0x26
#define ILI9488_DISPOFF 0x28
#define ILI9488_DISPON 0x29

#define ILI9488_CASET 0x2A
#define ILI9488_PASET 0x2B
#define ILI9488_RAMWR 0x2C
#define ILI9488_RAMRD 0x2E

#define ILI9488_PTLAR 0x30
#define ILI9488_MADCTL 0x36
#define ILI9488_PIXFMT 0x3A

#define ILI9488_FRMCTR1 0xB1
#define ILI9488_FRMCTR2 0xB2
#define ILI9488_FRMCTR3 0xB3
#define ILI9488_INVCTR 0xB4
#define ILI9488_DFUNCTR 0xB6

#define ILI9488_PWCTR1 0xC0
#define ILI9488_PWCTR2 0xC1
#define ILI9488_PWCTR3 0xC2
#define ILI9488_PWCTR4 0xC3
#define ILI9488_PWCTR5 0xC4
#define ILI9488_VMCTR1 0xC5
#define ILI9488_VMCTR2 0xC7

#define ILI9488_RDID1 0xDA
#define ILI9488_RDID2 0xDB
#define ILI9488_RDID3 0xDC
#define ILI9488_RDID4 0xDD

#define ILI9488_GMCTRP1 0xE0
#define ILI9488_GMCTRN1 0xE1
/*
#define ILI9488_PWCTR6 0xFC

*/

// Color definitions
#define ILI9488_BLACK 0x0000 /* 0, 0, 0 /
#define ILI9488_NAVY 0x000F / 0, 0, 128 /
#define ILI9488_DARKGREEN 0x03E0 / 0, 128, 0 /
#define ILI9488_DARKCYAN 0x03EF / 0, 128, 128 /
#define ILI9488_MAROON 0x7800 / 128, 0, 0 /
#define ILI9488_PURPLE 0x780F / 128, 0, 128 /
#define ILI9488_OLIVE 0x7BE0 / 128, 128, 0 /
#define ILI9488_LIGHTGREY 0xC618 / 192, 192, 192 /
#define ILI9488_DARKGREY 0x7BEF / 128, 128, 128 /
#define ILI9488_BLUE 0x001F / 0, 0, 255 /
#define ILI9488_GREEN 0x07E0 / 0, 255, 0 /
#define ILI9488_CYAN 0x07FF / 0, 255, 255 /
#define ILI9488_RED 0xF800 / 255, 0, 0 /
#define ILI9488_MAGENTA 0xF81F / 255, 0, 255 /
#define ILI9488_YELLOW 0xFFE0 / 255, 255, 0 /
#define ILI9488_WHITE 0xFFFF / 255, 255, 255 /
#define ILI9488_ORANGE 0xFD20 / 255, 165, 0 /
#define ILI9488_GREENYELLOW 0xAFE5 / 173, 255, 47 */
#define ILI9488_PINK 0xF81F

class ILI9488 : public Adafruit_GFX {

public:

ILI9488(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
int8_t _RST, int8_t _MISO);
ILI9488(int8_t _CS, int8_t _DC, int8_t _RST = -1);

void begin(void),
setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1),
setScrollArea(uint16_t topFixedArea, uint16_t bottomFixedArea),
scroll(uint16_t pixels),
pushColor(uint16_t color),
pushColors(uint16_t data, uint8_t len, boolean first),
drawImage(const uint8_t img, uint16_t x, uint16_t y, uint16_t w, uint16_t h),
fillScreen(uint16_t color),
drawPixel(int16_t x, int16_t y, uint16_t color),
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color),
setRotation(uint8_t r),
invertDisplay(boolean i);
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);

/* These are not for current use, 8-bit protocol only! /
uint8_t readdata(void),
readcommand8(uint8_t reg, uint8_t index = 0);
/
uint16_t readcommand16(uint8_t);
uint32_t readcommand32(uint8_t);
void dummyclock(void);
*/

void spiwrite(uint8_t),
writecommand(uint8_t c),
write16BitColor(uint16_t color),
writedata(uint8_t d),
commandList(uint8_t *addr);
uint8_t spiread(void);

private:
uint8_t tabcolor;

boolean hwSPI;

#if defined (AVR) || defined(TEENSYDUINO)
uint8_t mySPCR;
volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
////This def is for the Arduino.ORG M0!!!
//#elif defined(ARDUINO_SAM_ZERO)
// volatile PORT_OUT_Type *mosiport, *clkport, *dcport, *rsport, *csport;
// int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
// PORT_OUT_Type mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (STM32F1) || defined (VARIANT_ARDUINO_STM32) || defined (STM32F100xE) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
uint8_t mySPCR;
volatile uint32_t *mosiport, *clkport, *dcport, *rsport, *csport;
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (arm)
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (ESP8266)
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#else
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#endif
};

#endif

Ads ad-300x250

Skip to content

educ8s.tv – Watch Learn Build Logo

Arduino Touch Screen Tutorial

Arduino Touch Screen Tutorial

Hey guys, its Nick again, welcome to educ8s.tv a channel that is all about DIY electronics projects with Arduino, Raspberry Pi, ESP8266 and other popular boards. Today we are going to take a look at how to use the inexpensive, ILI9325 driver based, 2.8” touchscreen display designed for Arduino and at the end of this tutorial, you should be able to determine if this Touch Screen is a good option for your Arduino projects.

Arduino Touch Screen: 2.8″ Display with ILI9325 driver

I first came across this touchscreen which offers a resolution of 320×240 pixels, and an easy to use micro SD slot among several other great features on banggood.com and decided to buy it for use in some of my projects since it was inexpensive as it only costs around $11.

2.8″ Touchscreen Display

As shown in the video above, we will be performing simple tasks with the display to demonstrate how it works such that, When we press a button on the screen, a message will be displayed it. This means we will learn both how to create a button on the screen such that it can be touched and how to display messages on the screen.

As demonstrated the touch screen is working fine! Finally, we can start building projects with a touch screen which are much more interesting and easier to use.

Required Components/Parts and Where to Buy

The following components/parts are required to build this project and they can be bought by clicking on the links in front of them.

  1. 2.8″ Touch Screen ▶ https://educ8s.tv/part/TouchScreen28
  2. Arduino Uno ▶ https://educ8s.tv/part/ArduinoUno
  3. Arduino Mega ▶ https://educ8s.tv/part/ArduinoMega
  4. Xiaomi Powerbank ▶ https://educ8s.tv/part/Powerbank

Full disclosure: All of the links above are affiliate links. I get a small percentage of each sale they generate. Thank you for your support!

[adsense]

Schematics

The display comes as a shield which makes the connection with Arduino extremely easy, thus all that needs to be done for this project is to plug the display into the Arduino board since we won’t be adding any other sensor or actuator.

Connecting Screen to Arduino

One of the few downsides to this display is that it uses almost all of the digital and analog pins of the Arduino Uno which means when using this shield, we are left with only 2 digital pins and 1 analog pin for connections to other components that the project we are building might require.

Fortunately, this display works fine with the Arduino Mega, so when working on projects with more pin requirements and size is not really an issue, we can use the Arduino Mega instead of the Arduino Uno. Unfortunately, this display does not work with some other Arduino Uno form factor based boards like the Arduino Due or the Wemos D1 ESP8266 board due to pin compatibility and library Issues.

Let’s now see the software side of the project.

Code

In order to use this Arduino Touch Screen easily, we will need three libraries. We will need a modified version of the Adafruit TFTLCD library, the familiar Adafruit GFX library, and the Touchscreen library. All these libraries can be downloaded by following the links below.

Libraries

📥 Modified Adafruit TFTLCD: Download here

📥 Adafruit GFX: https://github.com/adafruit/Adafruit-GFX-Library

📥 Touchscreen: https://github.com/adafruit/Touch-Screen-Library

With the Libraries installed, we can test the display by trying out the examples which came with the libraries. Two favorite examples are the graphicstext example and the tftbmp example whose demonstration can be seen in the tutorial video.

To explore the Touchscreen functionality of the display, I have developed a sample code, which you can extend for use in any of your projects. it can be downloaded via the download link below.

To briefly explain the code, the first thing we do as usual is to include the libraries we will be using.

//////////////////////////////////////////////
  //        2.8" TOUCH SCREEN DEMO            //
 //                                          //
//           http://www.educ8s.tv           //
/////////////////////////////////////////////

#include <Adafruit_TFTLCD.h> 
#include <Adafruit_GFX.h>    
#include <TouchScreen.h>

Next, we declare the pins to which our screen is connected to on the Arduino both for the display and the touchscreen.

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

To use the touchscreen functionality of this display, there is a need for the display to be calibrated. To do this after uploading the code, Open the Serial Monitor and click (touch) on the top left corner of the display and write down the X and Y values displayed on the serial monitor. Then we edit the code to reflect those values. The X value goes to the TS_MAXX variable and the Y value goes to the TS_MAXY variable. We follow the same procedure for the other two variables. We click on the bottom right corner of the display and we enter the values we get in the TS_MINX and TS_MINY variables. With this done our display is now calibrated and ready for use.

#define TS_MINX 204
#define TS_MINY 195
#define TS_MAXX 948
#define TS_MAXY 910

Next, we declare the colors to be used with their hexadecimal values after which we create an object of the Adafruit TFTLCD library class indicating the variables used to represent the pins to which the screen is connected on the Arduino.

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

We also create an object of the touchscreen library indicating the pins to which the touch part of the screen is connected to on the Arduino.

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

Next, we write the Setup function.

We start the function by initializing the serial monitor and the LCD, after which we set the orientation of the LCD and fill the screen with a black color to serve as the background.

void setup() {
  Serial.begin(9600);
  Serial.print("Starting...");
  
  tft.reset();
  tft.begin(0x9325);
  tft.setRotation(1);
  
  tft.fillScreen(BLACK);

Next, we draw a white frame on the display then set the cursor to the desired location, change the text color to white, and print the “Hello” text on the screen. By following the same procedure, we display the red YouTube text as well.

//Draw white frame
  tft.drawRect(0,0,319,240,WHITE);
  
  //Print "Hello" Text
  tft.setCursor(100,30);
  tft.setTextColor(WHITE);
  tft.setTextSize(4);
  tft.print("Hello");
  
  //Print "YouTube!" text 
  tft.setCursor(80,100);
  tft.setTextColor(RED);
  tft.setTextSize(4);
  tft.print("YouTube!");

Next, we create the red youtube subscribe button. We do this by Creating a red rectangle and for our size requirements, we set the x and y pixel coordinates of the top left corner point of this rectangle to (60,180) after which we define the width for 200 pixels and the height as 40 pixels and  set the bottom right pixel coordinates of the rectangle to (260, 220). To make the rectangle look like a button, we then draw a similar white rectangle on the red rectangle and write the “subscribe” text on it.

//Create Red Button
  tft.fillRect(60,180, 200, 40, RED);
  tft.drawRect(60,180,200,40,WHITE);
  tft.setCursor(80,188);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("Subscribe!");

With the setup function all done, we move to the loop function, the algorithm in operation for the loop section is simple, each time the user clicks on the screen, we convert the point coordinates of the touch point into pixels using the Map function. After conversion, If that point is inside the red rectangle area, it means that the user has pressed the button, so we disable the button by setting this variable to false and we clear the screen so as to display the “thank you for subscribing” message on the screen.

void loop() 
{
  TSPoint p = ts.getPoint();  //Get touch point
  
  if (p.z > ts.pressureThreshhold) {

   Serial.print("X = "); Serial.print(p.x);
   Serial.print("tY = "); Serial.print(p.y);
   Serial.print("n");
   
   p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
   p.y = map(p.y, TS_MAXY, TS_MINY, 0, 240);
       
   if(p.x>60 && p.x<260 && p.y>180 && p.y<220 && buttonEnabled) 
   // The user has pressed inside the red rectangle
   {
    buttonEnabled = false; //Disable button
        
    //This is important, because the libraries are sharing pins
   pinMode(XM, OUTPUT);
   pinMode(YP, OUTPUT);
    
    //Erase the screen
    tft.fillScreen(BLACK);
    
    //Draw frame
    tft.drawRect(0,0,319,240,WHITE);
    
    tft.setCursor(50,50);
    tft.setTextColor(WHITE);
    tft.setTextSize(3);
    tft.print("Thank you fornn   subscribing!");
   }
   delay(10);  
  }
}

The code for this project can be downloaded by clicking on the link below.

——————–

CODE OF THE PROJECT
——————–

Upload the code to your Arduino board with the screen connected and you should see something like the image below.

Demo

That’s it for today’s tutorial guys, thanks for reading/watching. If you get stuck at any point while building this project, feel free to reach out to me via the comment section, I will be glad to answer whatever questions you might have. Don’t forget to share, like and subscribe on youtube. Thanks!

——————–

SUBSCRIBE ON YOUTUBE

——————–

Never miss a video: Subscribe to educ8s.tv

Nick2018-03-13T01:08:38+02:00

Share This Story, Choose Your Platform!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Page load link

Go to Top

Please be positive and constructive with your questions and comments.

User avatar

poynting

 
Posts: 5
Joined: Sun Aug 16, 2015 2:38 am

Adafruit_HX8357 library compile error (Teensy3.1)

I’ve purchased a 3.5″ TFT 320×480 + Touchscreen Breakout Board w/MicroSD Socket — HXD8357D
PRODUCT ID: 2050 and I’m trying to compile the graphicstest example in Adafruit_HX8357examplesgraphicstest.
for a Teensy3.1.

I’m using arduino 1.6.5 and Teensyduino 1.24

There seems to be no definition of «RwReg» in the include file Adafruit_HX8357.h, as shown by the error message shown below—

In file included from HX8357graphicstest.ino:19:0:
C:UsersDavidDocumentsArduinolibrariesAdafruit_HX8357/Adafruit_HX8357.h:167:14: error: ‘RwReg’ does not name a type
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;

Where is RwReg supposed to be defined, and what type should it be?

The graphicstest program begins with
#include <SPI.h>
#include «Adafruit_GFX.h»
#include «Adafruit_HX8357.h»

Thank you…



User avatar

poynting

 
Posts: 5
Joined: Sun Aug 16, 2015 2:38 am

Re: Adafruit_HX8357 library compile error (Teensy3.1)

Post

by poynting » Sun Aug 16, 2015 11:04 pm

Thank you. The example compiles and runs—as long as I choose software SPI.
If I try hardware SPI, the call to tft.begin(HX8357D) does not return.
I tried adding a member function to HX8357 class that called SPI.setMOSI(11),
SPI.setMISO(12), and SPI.setSCK(13), to set those pin numbers, and calling that before any
other calls into the HX8357 class, but that made no difference. Is there a better way?

Previously I successfully used hardware SPI with the ILI9341 class and example program
with an Adafruit 2.8″ touch LCD.
I’m hoping I can get hardware mode to work with this LCD.



User avatar

poynting

 
Posts: 5
Joined: Sun Aug 16, 2015 2:38 am

Re: Adafruit_HX8357 library compile error (Teensy3.1)

Post

by poynting » Mon Aug 17, 2015 9:04 pm

Here’s an additional puzzle. Using Arduino 1.0.6, I used the library TouchScreen along with the ILI9341 (all running on Teensy3.1) to build a touch-screen GUI. When I try to use TouchScreen in Arduino 1.6.5 (Teensyduino 1.24), I get compiler errors—

In file included from C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/wiring.h:33:0,
from C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/wiring_private.h:7,
from C:arduino-1.6.5ArduinohardwareteensyavrlibrariesTouchScreenTouchScreen.cpp:7:
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h: In function ‘void digitalWriteFast(uint8_t, uint8_t)’:
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h:887:24: error: ‘portSetRegister’ was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
^
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h:887:51: error: ‘digitalPinToBitMask’ was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
^
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h:889:26: error: ‘portClearRegister’ was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
^
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h:889:53: error: ‘digitalPinToBitMask’ was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
^
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h: In function ‘uint8_t digitalReadFast(uint8_t)’:
C:arduino-1.6.5Arduinohardwareteensyavrcoresteensy3/core_pins.h:976:32: error: ‘portInputRegister’ was not declared in this scope
return *portInputRegister(pin);
^
C:arduino-1.6.5ArduinohardwareteensyavrlibrariesTouchScreenTouchScreen.cpp: In member function ‘TSPoint TouchScreen::getPoint()’:
C:arduino-1.6.5ArduinohardwareteensyavrlibrariesTouchScreenTouchScreen.cpp:57:41: error: ‘digitalPinToPort’ was not declared in this scope
uint8_t xp_port = digitalPinToPort(_xp);
^
C:arduino-1.6.5ArduinohardwareteensyavrlibrariesTouchScreenTouchScreen.cpp:62:43: error: ‘digitalPinToBitMask’ was not declared in this scope
uint8_t xp_pin = digitalPinToBitMask(_xp);
^
C:arduino-1.6.5ArduinohardwareteensyavrlibrariesTouchScreenTouchScreen.cpp:73:30: error: ‘portOutputRegister’ was not declared in this scope
*portOutputRegister(yp_port) &= ~yp_pin;
^
Error compiling.

Maybe you can help me fix this, too!
Thank you, again,
Dave



User avatar

tinman123

 
Posts: 6
Joined: Mon Jan 13, 2014 9:12 am

Re: Adafruit_HX8357 library compile error (Teensy3.1)

Post

by tinman123 » Sun Dec 13, 2015 1:08 am

Hi Rick,
I was wondering if there has been any update on a teensy touchscreen library?
I have bought 25 of the 3.5 TFT screens (id:2050) and Teensy’s 3.2 to suit off adafruit for a project.
With the teensy the speed on the screen is quite quick in spi mode.
But I need to get the touch working otherwise I’ll need to change TFT screens.

If there is a Port available it would be much appreciated.

Cheers
Rodney



User avatar

tinman123

 
Posts: 6
Joined: Mon Jan 13, 2014 9:12 am

Re: Adafruit_HX8357 library compile error (Teensy3.1)

Post

by tinman123 » Sun Dec 13, 2015 8:30 pm

Hi Rick,
Thanks for the library. I did try it.
I’m using Arduino 1.6.6 and the teensyduino 1.26.
I am getting this error message still.
Ideas?

In file included from C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/wiring.h:33:0,
from C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/wiring_private.h:7,
from C:Arduinoarduino-1.6.6librariesTouchScreen_DueTouchScreen_Due.cpp:7:
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h: In function ‘void digitalWriteFast(uint8_t, uint8_t)’:
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h:1328:24: error: ‘portSetRegister’ was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
^
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h:1328:51: error: ‘digitalPinToBitMask’ was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
^
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h:1330:26: error: ‘portClearRegister’ was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
^
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h:1330:53: error: ‘digitalPinToBitMask’ was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
^
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h: In function ‘uint8_t digitalReadFast(uint8_t)’:
C:Arduinoarduino-1.6.6hardwareteensyavrcoresteensy3/core_pins.h:1432:32: error: ‘portInputRegister’ was not declared in this scope
return *portInputRegister(pin);
^
exit status 1
Error compiling.





User avatar

adafruit2

 
Posts: 21374
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.


hello all, this is probably too small of a problem compared to what i ve seen above, but i am trying to use the adafruit ssd1306 library so i can drive a small oled and i really don t have the knowledge to make it work

anyone has any pointer to make it work? currently it fails with ‘fatal error: avr/pgmspace.h: No such file or directory’

which makes sense as this is not an avr/arduino. but don t know what to do next

we don’t have «avr/pgmspace.h», but you may try to replace that with «pgmspace.h»

ah, will try, thanks. (you seem omnipresent :D )

well, that worked, but now i get cannot convert ‘volatile uint32_t {aka volatile unsigned int}’ to ‘PortReg*

i assume that s because the old and new libraries are returning different value types

can you point me to the code so i can take a look how PortReg is declared?

take a look at the .h file

#ifdef __SAM3X8E__
 typedef volatile RwReg PortReg;
 typedef uint32_t PortMask;
#else
  typedef volatile uint8_t PortReg;
  typedef uint8_t PortMask;
#endif

there is an ifdef for ARM and else for AVR

so i could make those volatile uint32_t

which would match with the esp libs

change that to #if defined( __SAM3X8E__ ) || defined( ESP8266 )

thanks again, removing some more stuff managed to make it compile, now to make it work :)

@igrr I really wish Arduino didn’t require the avr to include progmem.h
#include <avr/progmem.h>. It makes writing compatible libraries a little more annoying.

how about moving progmem.h to avr/progmem.h and adding progmem.h which will include avr/progmem.h as a fallback?

its a work around, a little misleading as this has nothing to do with Avr, but we didn’t create that problem ;-)

well i don’t actually see any other workaround…

agreed, are you doing this?

if you need this right now, do it and send the change. if not, i’ll do this a bit later tonight.

the config is moved as the flash size increases

it takes last 4 sectors of flash

so the SDK detects the «magic bytes» from the bootloader?

and switch the addr range

yeah, there’s a global «FlashChip» object which is set up on start

and sdk reads the flash size from there

so no problems here, perfect.

is there a reason why ESP8266WiFiClass::_getScanInfoByIndex is protected?

I prefer it public access it from outside :)

well the rationale is that scan_info is a struct from SDK, and in general i tried not to expose SDK types to the user

there is a bunch of methods to access fields of scan_info by index

yes then i need to add to new for channel and bssid and in my code i the call 4 function to get all info

BSSID should be there, i just haven’t implemented it

it’s in standard WiFi Shield library, so we need to have it

and you are welcome to add a new method for the channel

you may add something like getScanInfo(int index, String& ssid, String& BSSID, int& channel, …)

which will fill all the values in one go

i mean, BSSID should be there, but it’s not :)

as you see i have commented it out and forgot to add it back later

now I had in my 164 the Adafruit_SSD1306 and Adafruit_GFX libs

is there a way to install both so that they would work, because I want (do not have to) use the same arduino for developing both

but they are same libs but for differnt devices (so have changes)

these libs have been modified to use some stuff from Sming, which is not present in this distribution

i have asming insalled in c:tools

sming in c:toolssming (used choco)

but how does the IDE know about that?

the original Adafruit_GFX from Adafruit is working on the ESP8266

I have modified the packaging script to bundle the Adafruit ssd1306 lib with the board manager package

will deploy later tonight

gr8 i am looking forward to tha

not tested i have an ILI9341 display + Adafruit_GFX running here

oh wait that was Adafruit_ILI9341

thats exactly my next question

there was a discussion about SSD1306 though…

i have the 2 screens ssd1306 and that screen

@tzapu did you make any progress with Adafruit_ssd1306 lib?

if i can use the ili3941 with just the 4 spi pins that would be good

ILI9341 is working fine with up to 27fps

SPI + the D/C line and CS

how will i be able to get it? I mean i installed via boardmanager

i will update the board manager package later tonight

you will be able to install via board manager

also there is another display which is supported… esp8266/Arduino#271

don’t know if its useful for you though

no i have the ssd1306 and 3941

i want to connect a rotary encoder too (for controlling menu)

I have code that uses interupts, how do i use interrups in esp arduino?

just like you do it on an arduino — with attachInterrupt

so this code should just work?

well, remember not to do any lengthy stuff from the interrupts and you should be good

if it doesn’t, let me know

what are the pins numbers — is it just 4 — gpio4?

be warned that some ESP-12s (or 7s?) have gpio4 and gpio5 swapped

the silkscreen is incorrect on some of them

so if gpio4 doesn’t seem to work, try swapping them around

to be honest very few are actually correct

even the brand spanking new ESP-12E have them wrong

and it’s been out there for some time

interrupts should work as expected

no Interrupt vector there

it does not seem to work tried 12,14 tried 4,5

@igrr esp8266/Arduino#300 new WiFi functions :)

int encoderPin1 = 5;
int encoderPin2 = 4;

pinMode(encoderPin1, INPUT);
pinMode(encoderPin2, INPUT);

digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
digitalWrite(encoderPin2, HIGH); //turn pullup resistor on

//call updateEncoder() when any high/low changed seen
//on interrupt 0 (pin 2), or interrupt 1 (pin 3)
attachInterrupt(0, updateEncoder, CHANGE);
attachInterrupt(1, updateEncoder, CHANGE);

@alon24 what version of the IDE are you using?

attachInterrupt(encoderPin1, updateEncoder, CHANGE);

so can i use other pins? what is the correct line?

man… you have interrupt on ALL pins BUT pin 16 and analog input

oh, i am sorry, i did not check to see, i just did the copy/paste — my bad — checking

attachInterrupt([pin_number], [function], [type])

so tonight u add this screen, and u said that ssd1306 was talked about before, a few hours ago.

do u know if it is going to be inserted too soon? when?

i have no clue what screen you are talking about at all :)

you talked to somebody else

its the ili3941 and its done when igrr hast the time to build and upload it

igrr said that there was talk in the gitter about ssd1306

so i asked if anyone knows what the talk was since, the search does not show me that conversation, because I was not a memener

if someone can do a search on the right they will know

you have the spi or the i2c version?

why not use the Adafruit’s library?

@Links2004 in my latest push :) gzipped content streaming as well

SPIFFS_WebServer.png

well you need to comment a few lines

as far as I remember they have TWI = 0; and then restore

@ficeto — do you mean u r adding the lib soon?

a few times in the core functions

@ficeto it is yours, its a merge

no did not say such thing

i do not think addition is needed

so which lines to comment out?

a small edit on the original one and you can make it work

link me to the library source so i dont need to search for it

@ficeto u mean the adafruit — jas

line 27 from #ifdef SAM3X8E

#if defined(__SAM3X8E__) || defined(ESP8266)

that should compile the driver

@Links2004 isn’t the GFX lib alredy in?

works in original version

btw did you notice the new tool in the menu :) and the debug screen of the Arduino IDE on my screenshot

so here is my question, if i do this, and i use my ise for both arduino nano and esp dev, it will break the arduino nano use of ssd1306 — right?

you want to have twomasters at the same time?

if you want to ensure thefastest speed instead of commenting you can do the following

@ficeto yes looking really good, at he weekend i start the implementation for the webSocket server and after the Client.
i today get me 4MB SPI flash, so webserver incomming ;)

can the webserver handle more the one connection at the same time?

#if !defined(__SAM3X8E__) && !defined(ESP8266)

actually I think I’ll take on SSL first

@ficeto ok so the websocket server will use its own port for the beginning.

actually while working on a large request it’s easy to brick the esp

and async webserver second

i tested a telnet server with web server together and got it working

here is the telnet to serial part

#include <ESP8266WiFi.h>

#define MAX_SRV_CLIENTS 1
const char* ssid = "nbis-test";
const char* password = "1234567890";

WiFiServer server(21);
WiFiClient serverClients[MAX_SRV_CLIENTS];

void setup() {
  Serial1.begin(115200);
  //Serial1.setDebugOutput(true);
  WiFi.begin(ssid, password);
  Serial1.print("nConnecting to "); Serial1.println(ssid);
  uint8_t i = 0;
  while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
  if(i == 21){
    Serial1.print("Could not connect to"); Serial1.println(ssid);
    while(1) delay(500);
  }
  Serial.begin(115200);
  server.begin();
  server.setNoDelay(true);
  Serial1.print("Ready! Use 'telnet ");
  Serial1.print(WiFi.localIP());
  Serial1.println(" 21' to connect");
}

void loop() {
  uint8_t i;
  if (server.hasClient()){
    for(i = 0; i < MAX_SRV_CLIENTS; i++){
      if (!serverClients[i] || !serverClients[i].connected()){
        if(serverClients[i]) serverClients[i].stop();
        serverClients[i] = server.available();
        continue;
      }
    }
    //no free spot
    WiFiClient serverClient = server.available();
    serverClient.stop();
  }
  for(i = 0; i < MAX_SRV_CLIENTS; i++){
    if (serverClients[i] && serverClients[i].connected()){
      if(serverClients[i].available()){
        while(serverClients[i].available()) Serial.write(serverClients[i].read());
      }
    }
  }
  if(Serial.available()){
    size_t len = Serial.available();
    uint8_t sbuf[len];
    Serial.readBytes(sbuf, len);
    for(i = 0; i < MAX_SRV_CLIENTS; i++){
      if (serverClients[i] && serverClients[i].connected()){
        serverClients[i].write(sbuf, len);
        delay(1);
      }
    }
  }
}

tested with up to 4 clients

that’s not bad given that we have 5 TCP connections max :)

was lazy to poen more screens :D

then removed http and tested how well will the telnet work

why only 5 connections lwip can normally handle more, limit from espressif?

and with this code i got lots through

yes that’s a limit due to static memory allocation for the TCP stack

we can get over it by building lwIP from source

but I doubt we really need this

k, i have uIP running on a mega board with more the 5 connections ;)

different story because different hardware

can i look at that code btw?

what ethernet controller are you using with it?

.h file

if defined(SAM3X8E) || defined(ESP8266)

typedef volatile RwReg PortReg;
typedef uint32_t PortMask;

else

typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;

endif

.cpp file
// save I2C bitrate

if !defined(SAM3X8E) && !defined(ESP8266)//#ifndef SAM3X8E

uint8_t twbrbackup = TWBR;
TWBR = 12; // upgrade to 400KHz!

endif

if !defined(SAM3X8E) && !defined(ESP8266)//#ifndef SAM3X8E

TWBR = twbrbackup;

endif

@ficeto are those the changes need for the ssd1306?

after the commas shift+enter

now. cant i use wire.pins or something to change i2c pins? for sda scl?

use: wire.begin(sda, scl);
wire.pins are deprecated

the idea is that if you just need to change the pins so that the library which uses Wire.begin() will work, it’s okay

if you are writing a sketch, use Wire.begin(sda, scl)

perhaps need to remove that deprecation warning so not to scare people

or add some #warning there

In file included from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-LibraryAdafruit_GFX.cpp:35:0:
C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Libraryglcdfont.c:8:0: warning: "PROGMEM" redefined [enabled by default]
  #define PROGMEM
 ^
In file included from C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:38:0,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-LibraryAdafruit_GFX.h:5,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-LibraryAdafruit_GFX.cpp:34:
C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/pgmspace.h:15:0: note: this is the location of the previous definition
 #define PROGMEM     ICACHE_RODATA_ATTR
 ^
C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-LibraryAdafruit_GFX.cpp:39:0: warning: "pgm_read_byte" redefined [enabled by default]
  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 ^
In file included from C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:38:0,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-LibraryAdafruit_GFX.h:5,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-LibraryAdafruit_GFX.cpp:34:
C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/pgmspace.h:63:0: note: this is the location of the previous definition
 #define pgm_read_byte(addr)                                              
 ^
C:UsersilanDocumentsArduinolibrariesAdafruit_SSD1306Adafruit_SSD1306.cpp:19:26: fatal error: avr/pgmspace.h: No such file or directory
 #include <avr/pgmspace.h>
                          ^
compilation terminated.
Error compiling.

the #warning will also be trigger if the function is not used

@alon24 as a temporary workaround, replace avr/pgmspace.h with pgmspace.h

i’ll move the file in the next commit

@Links2004 took it, not compiling without changes

have it running here what for errors you get ?


In file included from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:35:0:
C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterglcdfont.c:8:0: warning: "PROGMEM" redefined [enabled by default]
  #define PROGMEM
 ^
In file included from C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:38:0,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.h:5,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:34:
C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/pgmspace.h:15:0: note: this is the location of the previous definition
 #define PROGMEM     ICACHE_RODATA_ATTR
 ^
C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:39:0: warning: "pgm_read_byte" redefined [enabled by default]
  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 ^
In file included from C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:38:0,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.h:5,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:34:
C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/pgmspace.h:63:0: note: this is the location of the previous definition
 #define pgm_read_byte(addr)                                              
 ^
C:UsersilanDocumentsArduinolibrariesAdafruit_SSD1306Adafruit_SSD1306.cpp:21:25: fatal error: util/delay.h: No such file or directory
  #include <util/delay.h>
                         ^
compilation terminated.
Error compiling.

the problem is in the Adafruit_SSD1306.cpp

#include "pgmspace.h"
#ifndef __SAM3X8E__
 #include <util/delay.h>
#endif

ok for removing the warnings simply

#ifndef pgm_read_byte
 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif

and

#ifndef PROGMEM
 #define PROGMEM
#endif

wow espressif did crazy stuff

#define MEMP_NUM_TCP_PCB                    (*((volatile uint32*)0x600011FC))

butt still is 5.

It appears I did not save before, so now I am getting this:

In file included from ssd1306_128x64_i2c.ino:22:0:
C:UsersilanDocumentsArduinolibrariesAdafruit_SSD1306/Adafruit_SSD1306.h:28:19: error: 'RwReg' does not name a type
  typedef volatile RwReg PortReg;
                   ^
C:UsersilanDocumentsArduinolibrariesAdafruit_SSD1306/Adafruit_SSD1306.h:164:3: error: 'PortReg' does not name a type
   PortReg *mosiport, *clkport, *csport, *dcport;
   ^
Error compiling

h file

#if defined(__SAM3X8E__) || defined(ESP8266)// #ifdef __SAM3X8E__
 typedef volatile RwReg PortReg;
 typedef uint32_t PortMask;
#else
  typedef volatile uint8_t PortReg;
  typedef uint8_t PortMask;
#endif

it seems that if denied esp8266 then it does not know RwReg here and PortReg

Removing the defined(esp8266) here gives an error:

In file included from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:35:0:
C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterglcdfont.c:8:0: warning: "PROGMEM" redefined [enabled by default]
  #define PROGMEM
 ^
In file included from C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:38:0,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.h:5,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:34:
C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/pgmspace.h:15:0: note: this is the location of the previous definition
 #define PROGMEM     ICACHE_RODATA_ATTR
 ^
C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:39:0: warning: "pgm_read_byte" redefined [enabled by default]
  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 ^
In file included from C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:38:0,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.h:5,
                 from C:UsersilanDocumentsArduinolibrariesAdafruit-GFX-Library-masterAdafruit_GFX.cpp:34:
C:UsersilanAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/pgmspace.h:63:0: note: this is the location of the previous definition
 #define pgm_read_byte(addr)                                              
 ^
C:UsersilanDocumentsArduinolibrariesAdafruit_SSD1306Adafruit_SSD1306.cpp:21:25: fatal error: util/delay.h: No such file or directory
  #include <util/delay.h>
                         ^
compilation terminated.
Error compiling.

I already added the 

#ifndef pgm_read_byte
 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif

#ifndef PROGMEM
 #define PROGMEM
#endif

to the cpp, maybe uit should be in the h file

i am going to bed, i give up for today — thanks for the help

hey, if anyone can just do the changes for sdd1306 and post them somewhere, that would be gr8. if not tomorrow is a new day. I will try again.

Понравилась статья? Поделить с друзьями:
  • Error running main cannot run program pycharm
  • Error running child killed unknown signal
  • Error rule can only have one resource source provided resource and test include exclude in
  • Error rpc failed curl 18 transfer closed with outstanding read data remaining
  • Error root this bundle is not valid