Difference between revisions of "Programming"

From The TinkerNet Wiki
Jump to navigation Jump to search
Line 64: Line 64:
 
===Memory Saving===
 
===Memory Saving===
 
[https://playground.arduino.cc/Main/PROGMEM PROGMEM]
 
[https://playground.arduino.cc/Main/PROGMEM PROGMEM]
 +
 +
===Some Libraries to Check Out===
 +
 +
* [https://github.com/thomasfredericks/Bounce2 Bounce2]
 +
* [https://github.com/JChristensen/JC_Button JC Button]
 +
*
  
 
=='''STUPID''' Library Compile Warnings!!!==
 
=='''STUPID''' Library Compile Warnings!!!==

Revision as of 14:06, 6 April 2021

Atom as a full IDE

bash

Dialogs

Some Links

C

C++

(Apparently, a language designed to make C programmers lose their minds...)

Converting numbers to strings

Problem Solving

  • Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '…'

Processing

JavaScript

Arduino (Language)

Data Type Conversions

char* to String

char *message = "Hello";
String myString = String(message);

String to char*

Messing about with strings & not Strings

http://www.cplusplus.com/reference/cstring/

Specifically: strcat

Memory Saving

PROGMEM

Some Libraries to Check Out

STUPID Library Compile Warnings!!!

Dear library writers,

Please fully debug your code before release.

It's not THAT difficult. Really.

I fully understand that compiler warnings do not indicate that your code will not work as expected, BUT, compiler warnings during a build are rather disconcerting.

Arduino Libraries

PubSubClient (2.8.0)

.pio/libdeps/SugarBush_SS_Climate_BME280/PubSubClient/src/PubSubClient.cpp: In member function 'boolean PubSubClient::publish_P(const char*, const uint8_t*, unsigned int, boolean)':

.pio/libdeps/SugarBush_SS_Climate_BME280/PubSubClient/src/PubSubClient.cpp:523:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

     return (rc == expectedLength);
                   ^

FIX: Add unsigned to the definition of expectedLength on line 487 of PubSubClient.cpp

SimpleTimer (0.0.0-alpha+sha.b30890b8f7)

.pio/libdeps/SugarBush_SS_Climate_BME280/SimpleTimer/SimpleTimer.cpp: In member function 'void SimpleTimer::run()':
 
.pio/libdeps/SugarBush_SS_Climate_BME280/SimpleTimer/SimpleTimer.cpp:66:60: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

if (current_millis - prev_millis[i] >= delays[i]) {
                                               ^

FIX: Add unsigned to the definition of delays[] on line 106 of SimpleTimer.h

Troubleshooting

When trying to compile things on a Linux machine...

You get silly-ass errors like fatal error: stdio.h: No such file or directory or other files missing that just don't make ANY sense...

  • sudo apt update
  • sudo apt install --reinstall build-essential

'Coz sumpin' borked yer compiler install...