- MG4 menetpróba
- Samsung Galaxy S24 Ultra - ha működik, ne változtass!
- Nem lesz idén Nothing Phone (3)
- Samsung Galaxy S23 Ultra - non plus ultra
- Samsung Galaxy Watch (Tizen és Wear OS) ingyenes számlapok, kupon kódok
- Poco X6 Pro - ötös alá
- T Phone 2 5G - kétszer olyan jó
- iPhone topik
- Fotók, videók mobillal
- Okosóra és okoskiegészítő topik
Hirdetés
-
Filléres Redmi érkezett
ma Az A3x nem kapott nagy bemutatót, egyszer csak felbukkant.
-
Pénzt akar a WhatsAppból a Meta, az AI majd segít
it Új AI-eszközöket kapnak a cégnek, a Meta célja, hogy több bevételt szedjen ki a WhatsAppból.
-
Computex 2024: monstrumhűtő a DeepCoolnál (videóval!)
ph Az Assassin IV széria legújabb verziója egy vapor chamber talpat kapott, így már 300 wattig használható.
-
Mobilarena
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
olli
tag
// Standard Arduino Mega/Due shield : <display model>,38,39,40,41
UTFT myGLCD(SSD1963_800480,38,39,40,41); //(byte model, int RS, int WR, int CS, int RST, int SER)UTouch myTouch( 43, 42, 44, 45, 46); //byte tclk, byte tcs, byte din, byte dout, byte irq
Ezekkel a beállításokkal?
A DUE-nak saját
#include <UTFT.h>
#include <URTouch.h>
könyvtára van.[ Szerkesztve ]
By cool !
-
olli
tag
[CODE// URTouch_ButtonTest
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a quick demo of how create and use buttons.
//
// This program requires the UTFT library.
//
// It is assumed that the display module is connected to an
// appropriate shield or that you know how to change the pin
// numbers in the setup.
//#include <UTFT.h>
#include <URTouch.h>// Initialize display
// ------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due : <display model>,25,26,27,28
// Teensy 3.x TFT Test Board : <display model>,23,22, 3, 4
// ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(CTE32,25,26,27,28);// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield : 15,10,14, 9, 8
// Standard Arduino Mega/Due shield : 6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due : 6, 5, 32, 3, 2
// Teensy 3.x TFT Test Board : 26,31,27,28,29
// ElecHouse TFT LCD/SD Shield for Arduino Due : 25,26,27,29,30
//
URTouch myTouch( 6, 5, 32, 3, 2);// Declare which fonts we will be using
extern uint8_t BigFont[];int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";/*************************
** Custom functions **
*************************/void drawButtons()
{
// Draw the upper row of buttons
for (x=0; x<5; x++)
{
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10+(x*60), 10, 60+(x*60), 60);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10+(x*60), 10, 60+(x*60), 60);
myGLCD.printNumI(x+1, 27+(x*60), 27);
}
// Draw the center row of buttons
for (x=0; x<5; x++)
{
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);
if (x<4)
myGLCD.printNumI(x+6, 27+(x*60), 87);
}
myGLCD.print("0", 267, 87);
// Draw the lower row of buttons
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10, 130, 150, 180);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10, 130, 150, 180);
myGLCD.print("Clear", 40, 147);
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (160, 130, 300, 180);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (160, 130, 300, 180);
myGLCD.print("Enter", 190, 147);
myGLCD.setBackColor (0, 0, 0);
}void updateStr(int val)
{
if (stCurrentLen<20)
{
stCurrent[stCurrentLen]=val;
stCurrent[stCurrentLen+1]='\0';
stCurrentLen++;
myGLCD.setColor(0, 255, 0);
myGLCD.print(stCurrent, LEFT, 224);
}
else
{
myGLCD.setColor(255, 0, 0);
myGLCD.print("BUFFER FULL!", CENTER, 192);
delay(500);
myGLCD.print(" ", CENTER, 192);
delay(500);
myGLCD.print("BUFFER FULL!", CENTER, 192);
delay(500);
myGLCD.print(" ", CENTER, 192);
myGLCD.setColor(0, 255, 0);
}
}// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
myGLCD.setColor(255, 0, 0);
myGLCD.drawRoundRect (x1, y1, x2, y2);
while (myTouch.dataAvailable())
myTouch.read();
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (x1, y1, x2, y2);
}/*************************
** Required functions **
*************************/void setup()
{
// Initial setup
myGLCD.InitLCD();
myGLCD.clrScr();myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);myGLCD.setFont(BigFont);
myGLCD.setBackColor(0, 0, 255);
drawButtons();
}void loop()
{
while (true)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();if ((y>=10) && (y<=60)) // Upper row
{
if ((x>=10) && (x<=60)) // Button: 1
{
waitForIt(10, 10, 60, 60);
updateStr('1');
}
if ((x>=70) && (x<=120)) // Button: 2
{
waitForIt(70, 10, 120, 60);
updateStr('2');
}
if ((x>=130) && (x<=180)) // Button: 3
{
waitForIt(130, 10, 180, 60);
updateStr('3');
}
if ((x>=190) && (x<=240)) // Button: 4
{
waitForIt(190, 10, 240, 60);
updateStr('4');
}
if ((x>=250) && (x<=300)) // Button: 5
{
waitForIt(250, 10, 300, 60);
updateStr('5');
}
}if ((y>=70) && (y<=120)) // Center row
{
if ((x>=10) && (x<=60)) // Button: 6
{
waitForIt(10, 70, 60, 120);
updateStr('6');
}
if ((x>=70) && (x<=120)) // Button: 7
{
waitForIt(70, 70, 120, 120);
updateStr('7');
}
if ((x>=130) && (x<=180)) // Button: 8
{
waitForIt(130, 70, 180, 120);
updateStr('8');
}
if ((x>=190) && (x<=240)) // Button: 9
{
waitForIt(190, 70, 240, 120);
updateStr('9');
}
if ((x>=250) && (x<=300)) // Button: 0
{
waitForIt(250, 70, 300, 120);
updateStr('0');
}
}if ((y>=130) && (y<=180)) // Upper row
{
if ((x>=10) && (x<=150)) // Button: Clear
{
waitForIt(10, 130, 150, 180);
stCurrent[0]='\0';
stCurrentLen=0;
myGLCD.setColor(0, 0, 0);
myGLCD.fillRect(0, 224, 319, 239);
}
if ((x>=160) && (x<=300)) // Button: Enter
{
waitForIt(160, 130, 300, 180);
if (stCurrentLen>0)
{
for (x=0; x<stCurrentLen+1; x++)
{
stLast[x]=stCurrent[x];
}
stCurrent[0]='\0';
stCurrentLen=0;
myGLCD.setColor(0, 0, 0);
myGLCD.fillRect(0, 208, 319, 239);
myGLCD.setColor(0, 255, 0);
myGLCD.print(stLast, LEFT, 208);
}
else
{
myGLCD.setColor(255, 0, 0);
myGLCD.print("BUFFER EMPTY", CENTER, 192);
delay(500);
myGLCD.print(" ", CENTER, 192);
delay(500);
myGLCD.print("BUFFER EMPTY", CENTER, 192);
delay(500);
myGLCD.print(" ", CENTER, 192);
myGLCD.setColor(0, 255, 0);
}
}
}
}
}
}
]URTouch.h
/*
URTouch.h - Arduino/chipKit library support for Color TFT LCD Touch screens
Copyright (C)2016 Rinky-Dink Electronics, Henning Karlsen. All right reservedBasic functionality of this library are based on the demo-code provided by
ITead studio.You can find the latest version of the library at
http://www.RinkyDinkElectronics.com/This library is free software; you can redistribute it and/or
modify it under the terms of the CC BY-NC-SA 3.0 license.
Please see the included documents for further information.Commercial use of this library requires you to buy a license that
will allow commercial use. This includes using the library,
modified or not, as a tool to sell products.The license applies to all part of the library including the
examples and tools supplied with the library.
*/#ifndef URTouch_h
#define URTouch_h#define URTOUCH_VERSION 201
#if defined(__AVR__)
#include "Arduino.h"
#include "hardware/avr/HW_AVR_defines.h"
#elif defined(__PIC32MX__)
#include "WProgram.h"
#include "hardware/pic32/HW_PIC32_defines.h"
#elif defined(__arm__)
#include "Arduino.h"
#include "hardware/arm/HW_ARM_defines.h"
#endif#define PORTRAIT 0
#define LANDSCAPE 1#define PREC_LOW 1
#define PREC_MEDIUM 2
#define PREC_HI 3
#define PREC_EXTREME 4class URTouch
{
public:
int16_t TP_X ,TP_Y;URTouch(byte tclk, byte tcs, byte tdin, byte dout, byte irq);
void InitTouch(byte orientation = LANDSCAPE);
void read();
bool dataAvailable();
int16_t getX();
int16_t getY();
void setPrecision(byte precision);void calibrateRead();
private:
regtype *P_CLK, *P_CS, *P_DIN, *P_DOUT, *P_IRQ;
regsize B_CLK, B_CS, B_DIN, B_DOUT, B_IRQ;
byte T_CLK, T_CS, T_DIN, T_DOUT, T_IRQ;
long _default_orientation;
byte orient;
byte prec;
byte display_model;
long disp_x_size, disp_y_size, default_orientation;
long touch_x_left, touch_x_right, touch_y_top, touch_y_bottom;void touch_WriteData(byte data);
word touch_ReadData();#if defined(ENERGIA)
volatile uint32_t* portOutputRegister(int value);
volatile uint32_t* portInputRegister(int value);
#endif
};#endif
By cool !
-
Tankblock
aktív tag
Szia,
Például a manuál elolvasása sokat segít:
[link] itt a User Manual.Nincs ilyen függvény definíció....
// töröltem a Manual sorait....
Szóval a megfelelő fv alkalmazása segít.
RMSVoltageMean
nek amyGLCD.printNumF(RMSVoltageMean , dec, x, y[, divider[, length[, filler]]]);
.....[ Szerkesztve ]
Release the Beast....
-
nagyúr
look into serial monitor to add or minus the value manually and key in here.
Pontosan hogyan tudom módosítani az értéket?Ezt a megadott kódrészletből nem lehet látni, azt a részt nem másoltad be.
Érintő képernyő + mega 2560 lesz az alap hardwer, az érintőképernyő
gombjaival ki lehet váltani a fizikai gombokat?Ki lehet, persze, de sokkal egyszerűbb lenne fizikai gombokkal kiváltani az eredeti gombokat. Eredetileg a kód szerint egy analóg lábra vannak kötve a gombok, valószínűleg ellenálláslétra segítségével különbözteti meg, hogy melyik gomb van lenyomva. Ezt 5 egyforma ellenállás segítségével le tudod modellezni, ha szeretnéd, vagy lehet úgy módosítani a kódot, hogy 1db gombot rákötve a select gombot érzékelje.
megoldás egy pwm lábon kiadni a feszültség szinteket az A0 lábra?
Ez több okból sem lenne megoldás.
[ Szerkesztve ]
-
nagyúr
Lyally
Legközelebb légyszi használd a kód beilleszthetése gombot vagy pastebin-t (vagy hasonlót).A select gomb nyomása ezt csinálja:
currentOffsetRead = 1; // to activate offset for current
voltageOffsetRead = 1; // to activate offset for voltage
powerOffsetRead = 1; // to activate offset for power
LCD.setCursor(0,0); /* set display words starting at upper left corner*/
LCD.print ("INITIALIZING..... ");
LCD.setCursor(0,1); /* set display words starting at lower left corner*/
LCD.print ("WAIT 5 SEC ..... ");Mi van, ha ezt a pár sort beteszed a setup-ba?
(Most nincs időm alaposabban megfejteni a kódot, hogy mit miért csinál.)[ Szerkesztve ]
-
nagyúr
Ha jól értem kimérted a gombokat és módosítottad a kódot az értékeknek megfelelően.
akkor nincs lenyomva az a gomb, valahol 400 és 600 közötti értéket mutat az A0.
Ez nem jó, akkor valami nincs jól bekötve. Gombnyomás nélkül a select gomb értéke fölötti értéket kellene mutatnia.
Hogy vannak bekötve a gombok? -
nagyúr
A SELECT-et 1024-600 értékre módosítva
Dehát így nincs olyan állapot, amikor azt érzékeli, hogy fel van engedve minden gomb! 800 fölött elvileg azt kellene érzékelni, hogy semmi sincs benyomva. Vagy ha nem 800, akkor mérd végig az összes gombhoz tartozó értéket, ha jól raktad össze, kell lenni egy jól megkülönböztethető nyugalmi értéknek.
-
olli
tag
[link] rtc_master
[link] oled könyvtár
[link] szintén,
ezek hiba nélkül fordítódnak esp32+ds3231 kódban.
Ami nem sikerül, az aktuális dátum/idő másnap, reset után, csak a fordítás időpontját mutatja.
25.50 C
20.25 C
32.00 C
Sending packet: 10
Saturday, March 04 2023 20:04:17
Mai állapot.
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 13
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress D0 = { 0x28, 0x31, 0xBF, 0x29, 0x07, 0x00, 0x00, 0x7D }; // "T1"
DeviceAddress D1 = { 0x28, 0x4F, 0x8E, 0x2A, 0x07, 0x00, 0x00, 0x37 }; // "T2"
/* for normal hardware wire use above */
#include <Wire.h>
#include <RtcDS3231.h>
RtcDS3231<TwoWire> Rtc(Wire);
// handy routine to return true if there was an error
// but it will also print out an error message with the given topic
bool wasError(const char* errorTopic = "")
{
uint8_t error = Rtc.LastError();
if (error != 0)
{
Serial.print("[");
Serial.print(errorTopic);
Serial.print("] WIRE communications error (");
Serial.print(error);
Serial.print(") : ");
switch (error)
{
case Rtc_Wire_Error_None:
Serial.println("(none?!)");
break;
case Rtc_Wire_Error_TxBufferOverflow:
Serial.println("transmit buffer overflow");
break;
case Rtc_Wire_Error_NoAddressableDevice:
Serial.println("no device responded");
break;
case Rtc_Wire_Error_UnsupportedRequest:
Serial.println("device doesn't support request");
break;
case Rtc_Wire_Error_Unspecific:
Serial.println("unspecified error");
break;
case Rtc_Wire_Error_CommunicationTimeout:
Serial.println("communications timed out");
break;
}
return true;
}
return false;
}
#include <Arduino.h>
#include "Wire.h"
#include "oled.h"
#include <WiFi.h>
#include "time.h"
#include <LoRa.h>
#include "secrets.h" // WiFi SSID & password
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#define RST 14 // GPIO14 -- SX1278's RESET
#define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
#define BAND 433E6
unsigned int counter = 0;
#define RTC_ADDRESS 0x68 // I2C eszköz címe
String rssi = "RSSI --";
String packSize = "--";
String packet ;
struct tm timeinfo;
static char msg[20]; // character buffer
OLED display = OLED(4, 15, 16, 0x3C, 128, 32, true); // SSD1306
void setup() {
pinMode(16,OUTPUT);
pinMode(25,OUTPUT);
digitalWrite(16, LOW); // set GPIO16 low to reset OLED
delay(50);
digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high
Serial.begin(115200);
while (!Serial);
SPI.begin(SCK,MISO,MOSI,SS);
LoRa.setPins(SS,RST,DI0);
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("init ok");
Wire.begin();
display.begin();
display.clear();
display.draw_string(4, 8, "RTC clock", OLED::DOUBLE_SIZE);
display.display();
//------- Initialize the Temperature measurement library--------------
sensors.begin();
sensors.setResolution(D0, 10); //T1
sensors.setResolution(D1, 10); //T2
}
void loop() {
sensors.requestTemperatures();
float T1 = sensors.getTempC(D0);
float T2 = sensors.getTempC(D1);
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(25, LOW); // turn the LED off by making the voltage LOW
delay(1000);
getTime(&timeinfo); // display time/date
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
RtcTemperature temp = Rtc.GetTemperature();
if (!wasError("loop GetTemperature"))
{
temp.Print(Serial);
// you may also get the temperature as a float and print it
// Serial.print(temp.AsFloatDegC());
Serial.println(" C ");
}
display.clear();
strftime (msg, 15, "%Y-%b-%d %a ", &timeinfo);
display.draw_string(16, 1, msg); // Display date
strftime (msg, 10, "%T ", &timeinfo); // Display time
display.draw_string(8, 12, msg, OLED::DOUBLE_SIZE);
display.display(); // Refresh screen
delay(3000);
display.clear();
display.setCursor(8,0);
display.println("T1= ");
display.setCursor(30,0);
display.println(T1);
display.setCursor(60, 0);
display.println(" C");
display.setCursor(8,12);
display.println("T2= ");
display.setCursor(30,12);
display.println(T2);
display.setCursor(60, 12);
display.println(" C");
display.display();
Serial.print(sensors.getTempC(D0));
Serial.println(" C");
Serial.print(sensors.getTempC(D1));
Serial.println(" C ");
}
//--- Convert decimal numbers to BCD -----------------------
byte decToBcd(byte val) {
return ( (val / 10 * 16) + (val % 10) );
}
//--- Convert BCD numbers to decimal ----------------------
byte bcdToDec(byte val) {
return ( (val / 16 * 10) + (val % 16) );
}
/*--- Set RTC time/date ------------------------------------
void setTime(struct tm* time) {
Wire.beginTransmission(RTC_ADDRESS);
Wire.write(0); // set register pointer to 00h
Wire.write(decToBcd(time->tm_sec)); // set seconds
Wire.write(decToBcd(time->tm_min)); // set minutes
Wire.write(decToBcd(time->tm_hour)); // set hours
Wire.write(time->tm_wday + 1); // set day of week (1=Sun, 7=Sat)
Wire.write(decToBcd(time->tm_mday)); // set date (1 to 31)
Wire.write(decToBcd(time->tm_mon) + 1); // set month
Wire.write(decToBcd(time->tm_year - 100)); // year from 2000 (0 to 99)
Wire.endTransmission();
}*/
//--- Read time/date from RTC ------------------------------
void getTime(struct tm* time) {
Wire.beginTransmission(RTC_ADDRESS);
Wire.write(0); // a kiolvasás kezdőcímének beállítása
Wire.endTransmission(false);
Wire.requestFrom(RTC_ADDRESS, 7); // Hét bájt kiolvasása (time/date)
time->tm_sec = bcdToDec(Wire.read() & 0x7f); // Másodpercek (0-59)
time->tm_min = bcdToDec(Wire.read()); // Percek (0 - 59)
time->tm_hour = bcdToDec(Wire.read() & 0x3f); // Órák (24h kijelzéshez)
time->tm_wday = bcdToDec(Wire.read() - 1); // Hét napja (0 - 6)
time->tm_mday = bcdToDec(Wire.read()); // hónap napja (1 - 31)
time->tm_mon = bcdToDec(Wire.read() - 1); // hónap sorszáma (0 - 11)
time->tm_year = bcdToDec(Wire.read()) + 100; // 1900-tól eltelt évek
}[ Szerkesztve ]
By cool !
-
lanszelot
addikt
igen, #19544 így telepítettem.
weiss:
igen, de akkor a blink se megy fel rá
ATmega328PB -t kell használnom semmi mással nem működik.ennél, ha loop ba rakom a kiírást akkor folyamatosan odébb gyalogoltatja , és egyidő után kimegy a kijelzőből.
hogyan tudom állandó helyre kiíratni?jelenleg itt tartok, de
- gyalogol a felirat,
- és nem kap értéket a hőmérőtől:#include <Adafruit_SSD1306.h>
#include <splash.h>
#include <max6675.h>
//Outputs from 6675 to arduino uno pins.
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 64, &Wire);
void setup() {
Serial.begin(9600);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(500);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
display.display();
delay(2000);
}
void loop() {
// For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
delay(1000);
display.clearDisplay(); //this line to clear previous logo
display.setTextColor(WHITE); //without this no display
display.print("C = ");
display.print(thermocouple.readCelsius());//your TEXT here
display.display(); //to shows or update your TEXT
}
[ Szerkesztve ]
-
lanszelot
addikt
Először is köszönöm szépen a választ.
Én nem találom egyikben sem a választ.
Mind a 3nál csak annyit fog mutatni, hogy mennyi ppm.
De mit mér azt nem tudni.
Az volt a kérdésem, hogy hogy lehet váltani a mérendő gázok között?
Legutolsó linkben is ott van, hogy több féle gáz mérésére képes.
De ennyi. Azt nem látom, hogy honnan tudni épp mit mér. -
its_grandpa
tag
Miért használod a LoRa library-t ?
Ez ugye nem valós LoRa hálózati kommunikáció mert LoRa.begin(433E6) de a LoRa 867 – 868MHz-es Magyarországon.
LoRa példa itt [link]
A packet összerakásakor kell még 2 sor szvsz.
LoRa.print("Relay state: ");
LoRa.print(r_state);
A vett üzenet parse-olásra meg találsz példát a link-ben. -
bagarol
junior tag
[link] Itt már írtam.
LoRa.beginPacket();
LoRa.print(state,"hello ",T1," ",T2," ",counter);
LoRa.endPacket();if (packetSize) {
// received a packet
state = ((char)LoRa.read());
Serial.print("Received packet :");
// read packet
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi()); -
Janos250
őstag
Pl. így hirtelenjében valami hasonló. Lehet persze, szebben is, de maradjunk az eredeti átírásánál.
uint8_t inChar[packetSizeMax] ;
uint8_t i = 0 ;
while (LoRa.available()) {
inChar[i] = (char)LoRa.read());
Serial.print((char)inChar[i]));
i++ ;
// Serial.print((char)LoRa.read());
}
Aztán, amikor már tudod, hogy hol kezdődik, akkor vagy substringgel kiszeded, vagy rádefiniálsz egy másik tömböt arra a területre, ahol van (erre már írtam példát korábban). Én az utóbbit szeretem, de tökmindegy.Az amerikaiak $ milliókért fejlesztettek golyóstollat űrbéli használatra. Az oroszok ceruzát használnak. Én meg arduinot.
-
vargalex
félisten
Szia!
Ugyan én nem nagyon szoktam használni a String osztályt, de most az egyszerűség kedvéért (kipróbálni ugyan nem tudtam, de szerintem működnie kell):
#include <SPI.h>
#include <LoRa.h>
unsigned int state;
//LoRa32u4 ports
#define SS 8
#define RST 4
#define DI0 7
#define BAND 433E6
void setup() {
Serial.begin(115200);
pinMode(13, OUTPUT); // fehér led sets the pin as output for relay
digitalWrite(13,HIGH);
//while (!Serial); //if just the the basic function, must connect to a computer
delay(1000);
SPI.begin();
LoRa.setPins(SS,RST,DI0);
Serial.println("LoRa Receiver");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("LoRa Initial OK!");
}
/*----( LOOP: RUNS CONSTANTLY )----*/
void loop() {
digitalWrite(13,LOW); // try to parse packet
int packetSize = LoRa.parsePacket();
String message = ""
if (packetSize) { // received a packet
while (LoRa.available()) {
message += (char)LoRa.read();
}
Serial.print("Received packet :");
Serial.print(message);
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
Serial.print("Status: ");
Serial.println(message.charAt(0));
}
}A korrekt megoldás valóban inkább az lenne, hogy saját struktúrát definiálni és annak a címét beállítani a beolvasott tömb címére (persze ekkor fix méretekkel kell dolgozni).
[ Szerkesztve ]
Alex
Új hozzászólás Aktív témák
- Eladó konfig! Ryzen 5 5600X 512GB M.2 SSD 16GB DDR4 RTX 3060Ti 8GB!
- MacBook Pro Retina 13" M1 Chip / 16GB RAM / 2TB SSD / Magyar / 60 nap garancia
- Apple Watch S9 41mm Pink Aluminum, bontatlan
- HP 27-cr0757nz - ÚJ 27"-os FullHD All-IN-ONE PC - i7-1355U, 32GB, 1TB SSD, W11, 300nit
- Eladó Fujifilm X100T fekete
Állásajánlatok
Cég: Ozeki Kft.
Város: Debrecen