Settimino and M5 Paper, interacting weirdly
-
Basically, M5Paper has a unique version of the I2C clock integrated into it. This version is causing conflicts with a Platform.h based program.
The Error it keeps on pitching is that macro "min" requires 2 arguments, but only is presented with 1.
the 8 bit integer could, technically, handle 60 minutes, however it wants "mm" not "m" in there. So i grabbed another RTC, and when i did , it broke everything. So i have to re-integrate the original I2C.h
Any solution for this? I am trying to integrate this to step7. And it seemingly would work if there is a Serial Print function for M5Paper. I do not see that available, as it is actually "Canvas Draw" which leads to confusing integration.
Any help would be great, my code is as follows:
*----------------------------------------------------------------------
Data Read DemoCreated 12 Dec 2016
Modified 10 Mar 2019 for Settimino 2.0.0
by Davide Nardella
This demo shows how to read data from the PLC.
A DB with at least 1024 byte into the PLC is needed.
Specify its number into DBNum variable- Both small and large data transfer are performed (see DO_IT_SMALL)
- During the loop, try to disconnect the ethernet cable.
The system will report the error and will reconnect automatically
when you re-plug the cable. - For safety, this demo doesn't write data into the PLC, try
yourself to change ReadArea with WriteArea. - This demo uses ConnectTo() with Rack=0 and Slot=2 (S7300)
- If you want to connect to S71200/S71500 change them to Rack=0, Slot=0.
- If you want to connect to S7400 see your hardware configuration.
- If you want to work with a LOGO 0BA7 or S7200 please refer to the
documentation and change
Client.ConnectTo(<IP>, <Rack>, <Slot>);
with the couple
Client.SetConnectionParams(<IP>, <LocalTSAP>, <Remote TSAP>);
Client.Connect();
----------------------------------------------------------------------*/
#include <M5EPD.h>
#include <Settimino.h>
//Define Canvas Type
M5EPD_Canvas canvas(&M5.EPD);
// Uncomment next line to perform small and fast data access
#define DO_IT_SMALL// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0F, 0x08, 0xE1 };IPAddress Local(192,168,0,90); // Local Address
IPAddress PLC(192,168,0,12); // PLC Address// Following constants are needed if you are connecting via WIFI
// The ssid is the name of my WIFI network (the password obviously is wrong)
char ssid[] = "SKYNET-AIR"; // Your network SSID (name)
char pass[] = "yourpassword"; // Your network password (if any)
IPAddress Gateway(192, 168, 0, 1);
IPAddress Subnet(255, 255, 255, 0);int DBNum = 100; // This DB must be present in your PLC
byte Buffer[1024];S7Client Client;
unsigned long Elapsed; // To calc the execution time
//----------------------------------------------------------------------
// Setup : Init Ethernet and Serial port
//----------------------------------------------------------------------
void setup() {
M5.begin();
M5.EPD.SetRotation(0);
M5.EPD.Clear(true);
M5.RTC.begin();
canvas.createCanvas(960, 540);
canvas.setTextSize(3);
// Open serial communications and wait for port to open:
Serial.begin(115200);#ifdef S7WIFI
//--------------------------------------------- ESP8266 Initialization
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
WiFi.config(Local, Gateway, Subnet);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("Local IP address : ");
Serial.println(WiFi.localIP());
#else
//--------------------------------Wired Ethernet Shield Initialization
// Start the Ethernet Library
EthernetInit(mac, Local);
// Setup Time, someone said me to leave 2000 because some
// rubbish compatible boards are a bit deaf.
delay(2000);
Serial.println("");
Serial.println("Cable connected");
Serial.print("Local IP address : ");
Serial.println(Ethernet.localIP());
#endif
}
//----------------------------------------------------------------------
// Connects to the PLC
//----------------------------------------------------------------------
bool Connect()
{
int Result=Client.ConnectTo(PLC,
0, // Rack (see the doc.)
2); // Slot (see the doc.)
Serial.print("Connecting to ");Serial.println(PLC);
if (Result==0)
{
Serial.print("Connected ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
}
//----------------------------------------------------------------------
// Dumps a buffer (a very rough routine)
//----------------------------------------------------------------------
void Dump(void *Buffer, int Length)
{
int i, cnt=0;
pbyte buf;if (Buffer!=NULL)
buf = pbyte(Buffer);
else
buf = pbyte(&PDU.DATA[0]);Serial.print("[ Dumping ");Serial.print(Length);
Serial.println(" bytes ]===========================");
for (i=0; i<Length; i++)
{
cnt++;
if (buf[i]<0x10)
Serial.print("0");
Serial.print(buf[i], HEX);
Serial.print(" ");
if (cnt==16)
{
cnt=0;
Serial.println();
}
}
Serial.println("===============================================");
}
//----------------------------------------------------------------------
// Prints the Error number
//----------------------------------------------------------------------
void CheckError(int ErrNo)
{
Serial.print("Error No. 0x");
Serial.println(ErrNo, HEX);// Checks if it's a Severe Error => we need to disconnect
if (ErrNo & 0x00FF)
{
Serial.println("SEVERE ERROR, disconnecting.");
Client.Disconnect();
}
}
//----------------------------------------------------------------------
// Profiling routines
//----------------------------------------------------------------------
//void MarkTime()
//{
// Elapsed=millis();
//}
//----------------------------------------------------------------------
//void ShowTime()
//{
// Calcs the time
//Elapsed=millis()-Elapsed;
// Serial.print("Job time (ms) : ");
// Serial.println(Elapsed);
//}
//----------------------------------------------------------------------
// Main Loop
//----------------------------------------------------------------------
void loop()
{
int Size, Result;
void *Target;#ifdef DO_IT_SMALL
Size=64;
Target = NULL; // Uses the internal Buffer (PDU.DATA[])
#else
Size=1024;
Target = &Buffer; // Uses a larger buffer
#endif// Connection
while (!Client.Connected)
{
if (!Connect())
delay(500);
}Serial.print("Reading ");Serial.print(Size);Serial.print(" bytes from DB");Serial.println(DBNum);
// Get the current tick
MarkTime();
Result=Client.ReadArea(S7AreaDB, // We are requesting DB access
DBNum, // DB Number
0, // Start from byte N.0
Size, // We need "Size" bytes
Target); // Put them into our target (Buffer or PDU)
if (Result==0)
{
//ShowTime();
Dump(Target, Size);
}
else
CheckError(Result);
Result[3]="/0";
M5.begin();
M5.EPD.SetRotation(0);
M5.EPD.Clear(true);
M5.RTC.begin();
canvas.createCanvas(960, 540);
canvas.setTextSize(3);
canvas.drawString((char*)Result, 0, 0);
canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
delay(500);
} -
kind-of answered my own question. Canvas Draw = Serial Print. So its just transposition or , well, commenting out. I chose commenting out for the time being. Target Not results.
-
In file included from c:\Users\KSHAW47\Documents\Arduino\libraries\M5EPD\src/M5EPD.h:11,
from C:\Users\KSHAW47\Documents\Arduino\ReadDemo_M5Paper\ReadDemo_M5Paper.ino:31:
c:\Users\KSHAW47\Documents\Arduino\libraries\M5EPD\src/utility/BM8563.h:10:30: error: macro "min" requires 2 arguments, but only 1 given
RTC_Time() : hour(), min(), sec() {
^
c:\Users\KSHAW47\Documents\Arduino\libraries\M5EPD\src/utility/BM8563.h:12:60: error: macro "min" requires 2 arguments, but only 1 given
RTC_Time(int8_t h, int8_t m, int8_t s) : hour(h), min(m), sec(s) {came back again, no known solution. please help
-
Is there a possibility that it is conflicting with the Arduino macro?
#define min(a,b) ((a)<(b)?(a):(b))This is a rough way of writing it, but in the header
#include <M5EPD.h> #include <Settimino.h> #undef minWill it compile if I undef it?
However, in this case, the standard min cannot be used in this file.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login