Notifications
Clear all

Post code test

19 Posts
3 Users
1 Reactions
1,105 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Using <> after IDE 2.0.0 Copy for Forum (Markdown)

```cpp
int8_t PCintPort::addPin(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, uint8_t mode)
{
	PCintPin* tmp;
	tmp=firstPin;
	if (firstPin != NULL) {
		do {
			if (tmp->arduinoPin == arduinoPin) { enable(tmp, userFunc, mode); return(0); }
			if (tmp->next == NULL) break;
			tmp=tmp->next;
		} while (true);
	}
```

Using {;} after IDE 2.0.0 Copy for Forum (Markdown)

 

```cpp int8_t PCintPort::addPin(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, uint8_t mode) { PCintPin* tmp; tmp=firstPin; if (firstPin != NULL) { do { if (tmp->arduinoPin == arduinoPin) { enable(tmp, userFunc, mode); return(0); } if (tmp->next == NULL) break; tmp=tmp->next; } while (true); } ```

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Following the HELP steps. Simple select and copy from source, paste into here after a couple blank lines and add a couple blank lines after.

 

const char*macToString(uint8_tmac[6]) {
staticchars[20];
sprintf(s, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return s;
}
 

 

 

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

Using <> after IDE 2.0.0 Copy for Forum (Markdown)

```cpp
int8_t PCintPort::addPin(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, uint8_t mode)
{
	PCintPin* tmp;
	tmp=firstPin;
	if (firstPin != NULL) {
		do {
			if (tmp->arduinoPin == arduinoPin) { enable(tmp, userFunc, mode); return(0); }
			if (tmp->next == NULL) break;
			tmp=tmp->next;
		} while (true);
	}
```

Using {;} after IDE 2.0.0 Copy for Forum (Markdown)

 

```cpp int8_t PCintPort::addPin(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, uint8_t mode) { PCintPin* tmp; tmp=firstPin; if (firstPin != NULL) { do { if (tmp->arduinoPin == arduinoPin) { enable(tmp, userFunc, mode); return(0); } if (tmp->next == NULL) break; tmp=tmp->next; } while (true); } ```

As I mentioned else thread... the new Arduino IDE does not offer saving your code to HTML - I don't know why, but if you have an account, I'm sure they will look at any enhancement requests put to them, as their issue tracker seems to have many enhancement requests already recorded on their GitHub site.

Cheers


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Following the HELP instructions on code posting, I never did it this way.

 

 

 

/*
Blink


Turns an LED on for one second, then off for one second, repeatedly.


Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
 https://www.arduino.cc/en/Main/Products 


modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman


This example code is in the public domain.


 https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink 
*/


// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}


// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Now use the IDE copy for forum

```cpp
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
```

Don't see much difference.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

Following the HELP instructions on code posting, I never did it this way. 

/*
Blink


Turns an LED on for one second, then off for one second, repeatedly.


Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
 https://www.arduino.cc/en/Main/Products 


modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman


This example code is in the public domain.


 https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink 
*/


// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}


// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Now use the IDE copy for forum

```cpp
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
```

Don't see much difference.

The [CODE] tag preserves whitespace, that's all, no syntax highlighting... so, if you format your code in the Arduino IDE just the way you like it, then select it all, and copy for forum, and then... select the "<>" menu option on the forum, and paste your code in there... it will then be displayed with all the whitespace and indentation you intended it to look like.

Cheers

 


   
Ron reacted
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @frogandtoad

The [CODE] tag preserves whitespace, that's all, no syntax highlighting... so, if you format your code in the Arduino IDE just the way you like it, then select it all, and copy for forum, and then... select the "<>" menu option on the forum, and paste your code in there... it will then be displayed with all the whitespace and indentation you intended it to look like.

Cheers

Interestingly, the Arduino IDE 2 has the ability to copy formatted code, if the editor you're pasting into supports it - Try copy some code directly into LibreOffice Writer for example, or use the "Paste Special" option to see some options.

Cheers


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Using both the <> (Code) tag above and the {;} (Source Code) tag above to show the difference.

Clearly for the new IDE 2, the <> (Code) tag is better. However with no copy as HTML, we have lost the color coding.

First the <>

#include <IBusBM.h>

IBusBM IBus;  // IBus object

/*
  For a given ESP32 serial port. rxPin and txPin can be specified for the serial ports 1 and 2 of ESP32 architectures 
  (default to RX1=9, TX1=10, RX2=16, TX2=17).
*/

//#define RX2  16

/*
  Read the number of a given channel and convert to the range provided.
  If the channel is off, return the default value
*/

int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) {
  uint16_t ch = IBus.readChannel(channelInput);
  if (ch < 100) return defaultValue;
  return map(ch, 1000, 2000, minLimit, maxLimit);
}

// Read the channel and return a boolean value
bool readSwitch(byte channelInput, bool defaultValue) {
  int intDefaultValue = (defaultValue) ? 100 : 0;
  int ch = readChannel(channelInput, 0, 100, intDefaultValue);
  return (ch > 50);
}
void setup() {
  // Start serial monitor
  Serial.begin(115200);
  IBus.begin(Serial2, 1);  // iBUS object connected to serial2 RX2 pin using timer 1
}
void loop(){}

Second the {;}

#include IBusBM IBus; // IBus object /* For a given ESP32 serial port. rxPin and txPin can be specified for the serial ports 1 and 2 of ESP32 architectures (default to RX1=9, TX1=10, RX2=16, TX2=17). */ //#define RX2 16 /* Read the number of a given channel and convert to the range provided. If the channel is off, return the default value */ int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) { uint16_t ch = IBus.readChannel(channelInput); if (ch < 100) return defaultValue; return map(ch, 1000, 2000, minLimit, maxLimit); } // Read the channel and return a boolean value bool readSwitch(byte channelInput, bool defaultValue) { int intDefaultValue = (defaultValue) ? 100 : 0; int ch = readChannel(channelInput, 0, 100, intDefaultValue); return (ch > 50); } void setup() { // Start serial monitor Serial.begin(115200); IBus.begin(Serial2, 1); // iBUS object connected to serial2 RX2 pin using timer 1 } void loop(){}

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

3rd test using Copy for Forum (Markdown) still no color.

case 1 <>

```cpp
#include <IBusBM.h>

IBusBM IBus;  // IBus object

/*
  For a given ESP32 serial port. rxPin and txPin can be specified for the serial ports 1 and 2 of ESP32 architectures 
  (default to RX1=9, TX1=10, RX2=16, TX2=17).
*/

//#define RX2  16

/*
  Read the number of a given channel and convert to the range provided.
  If the channel is off, return the default value
*/

int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) {
  uint16_t ch = IBus.readChannel(channelInput);
  if (ch < 100) return defaultValue;
  return map(ch, 1000, 2000, minLimit, maxLimit);
}

// Read the channel and return a boolean value
bool readSwitch(byte channelInput, bool defaultValue) {
  int intDefaultValue = (defaultValue) ? 100 : 0;
  int ch = readChannel(channelInput, 0, 100, intDefaultValue);
  return (ch > 50);
}
void setup() {
  // Start serial monitor
  Serial.begin(115200);
  IBus.begin(Serial2, 1);  // iBUS object connected to serial2 RX2 pin using timer 1
}
void loop(){}

```

 

Case 2 {;}

 

```cpp #include IBusBM IBus; // IBus object /* For a given ESP32 serial port. rxPin and txPin can be specified for the serial ports 1 and 2 of ESP32 architectures (default to RX1=9, TX1=10, RX2=16, TX2=17). */ //#define RX2 16 /* Read the number of a given channel and convert to the range provided. If the channel is off, return the default value */ int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) { uint16_t ch = IBus.readChannel(channelInput); if (ch < 100) return defaultValue; return map(ch, 1000, 2000, minLimit, maxLimit); } // Read the channel and return a boolean value bool readSwitch(byte channelInput, bool defaultValue) { int intDefaultValue = (defaultValue) ? 100 : 0; int ch = readChannel(channelInput, 0, 100, intDefaultValue); return (ch > 50); } void setup() { // Start serial monitor Serial.begin(115200); IBus.begin(Serial2, 1); // iBUS object connected to serial2 RX2 pin using timer 1 } void loop(){} ```

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Test 4 using the Help method (Copy)

Case 1 <>

#include <IBusBM.h>


IBusBM IBus; // IBus object


/*
For a given ESP32 serial port. rxPin and txPin can be specified for the serial ports 1 and 2 of ESP32 architectures
(default to RX1=9, TX1=10, RX2=16, TX2=17).
*/


//#define RX2 16


/*
Read the number of a given channel and convert to the range provided.
If the channel is off, return the default value
*/


int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) {
uint16_t ch = IBus.readChannel(channelInput);
if (ch < 100) return defaultValue;
return map(ch, 1000, 2000, minLimit, maxLimit);
}


// Read the channel and return a boolean value
bool readSwitch(byte channelInput, bool defaultValue) {
int intDefaultValue = (defaultValue) ? 100 : 0;
int ch = readChannel(channelInput, 0, 100, intDefaultValue);
return (ch > 50);
}
void setup() {
// Start serial monitor
Serial.begin(115200);
IBus.begin(Serial2, 1); // iBUS object connected to serial2 RX2 pin using timer 1
}
void loop(){}

 

Case 2 {;}

#include <IBusBM.h>

IBusBM IBus; // IBus object

/*
For a given ESP32 serial port. rxPin and txPin can be specified for the serial ports 1 and 2 of ESP32 architectures
(default to RX1=9, TX1=10, RX2=16, TX2=17).
*/

//#define RX2 16

/*
Read the number of a given channel and convert to the range provided.
If the channel is off, return the default value
*/

int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) {
uint16_t ch = IBus.readChannel(channelInput);
if (ch < 100) return defaultValue;
return map(ch, 1000, 2000, minLimit, maxLimit);
}

// Read the channel and return a boolean value
bool readSwitch(byte channelInput, bool defaultValue) {
int intDefaultValue = (defaultValue) ? 100 : 0;
int ch = readChannel(channelInput, 0, 100, intDefaultValue);
return (ch > 50);
}
void setup() {
// Start serial monitor
Serial.begin(115200);
IBus.begin(Serial2, 1); // iBUS object connected to serial2 RX2 pin using timer 1
}
void loop(){}

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Trying again, used IDE 2.1.0 Copy and {;}

 

void setup(){ } void loop() { uint8_t pin = 2; int value = LOW; analogWrite(pin, value); }

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Now trying <>

void setup(){
}

void loop() {
  uint8_t pin = 2;
  int value = LOW;

  analogWrite(pin, value);
}

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Now Copy for forum markdown and {;}

 

```cpp void setup(){ } void loop() { uint8_t pin = 2; int value = LOW; analogWrite(pin, value); } ```

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7410
Topic starter  

Now Copy for forum markdown and <>

```cpp
void setup(){
}

void loop() {
  uint8_t pin = 2;
  int value = LOW;

  analogWrite(pin, value);
}
```

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Page 1 / 2