¿ªÔÆÌåÓý

Nextion Tune Button


 

Hey, Sam.

On my Zombie Apocalypse Survival HF Go-Kit (work in progress), the front panel has a momentary spst switch that essentially mimics a CW key.? So, I might suggest exploring the addition of a 2N7000 across the CW key line and assign one of the digital outputs freed up by use of a Nextion screen, to turn this transistor on and off (and henceforth use for tuning).? I suppose a virtual key, functioning in a latch mode, needs to be designed and inserted into one of the popular Nextion screen firmware versions to activate/deactivate a certain digital oitput.

Theoretically.........



-Ted
K3RTA


James Lynes
 

Shouldn't need any hardware to implement this feature. Just create a screen button that sets and resets the same variable that is toggled by the ptt or cw key io pin.

James


 

Call sign at Yahoo is best.

Tnx,


Ted?
k3rta



 

James,

Thanks. I really just need to try to learn.? After having tried to work with stepper motors and multiple PID sketches unsuccessfully, Arduino programming has left a bad taste in my mouth.

I envision a tab that will throw on a CW key up until pressed a second time, or time out in 15 seconds or so if not manually shut off.? Having two brothers who are programmers, I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

Ted
K3RTA


Jack Purdum
 

I know of a pretty good book if you're interested!! Some research: Read the Amazon reviews on Beginning C for Arduino to see if it appears that the book meets your needs. Make sure you look at the 2nd edition. It has additional material plus a gentle introduction to C++ so you can kinda understand what's going on with libraries, almost all of which are written in C++.

Jack, W8TEE

On Tuesday, March 12, 2019, 11:11:13 AM EDT, Ted via Groups.Io <k3rta@...> wrote:


James,

Thanks. I really just need to try to learn.? After having tried to work with stepper motors and multiple PID sketches unsuccessfully, Arduino programming has left a bad taste in my mouth.

I envision a tab that will throw on a CW key up until pressed a second time, or time out in 15 seconds or so if not manually shut off.? Having two brothers who are programmers, I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

Ted
K3RTA


 

Ted,

As a starting point, the code below should come close to doing what you want.
It has not been debugged.
And you will have to figure out how to implement? ?"tune_button_is_pressed"

Good to learn how to program a bit, and figuring out the Raduino is a very good place to start.
A good first program might be a stripped down thing that just writes to the LCD display.
And I suggest you ignore all that C++ stuff, concentrate on learning to program in vanilla C

Another bit of advice:?
Ignore all the subsequent posts from other forum denizens
regarding coding style and indentation and variable names and favorite programming languages
and how it was done back in the 1950's.? ;-)

An alternate way to implement this is to plug a straight key into the uBitx,? put a brick on it.? ? ;-)

Jerry, KE7ER


########################################################################
###########? ?Old code, near bottom of Farhan's ubitx_20.ino for the stock uBitx firmware:

void loop(){
? cwKeyer();
?

###############################################################
#################? New code, replace the old code with this:
?
void loop(){
? cwKeyer();
?
? if (tune_button_is_pressed) {
? ? short timer = 0;? ? // declare a 16 bit integer, initialize its value to zero
? ? delay(50);? ? ? ? ? // debounce for 50 milliseconds (needed if button is a mechanical switch)
?
? ? startTx(TX_CW);? ? ?// Put rig into CW transmit mode with CLK2 = transmit frequency
? ? cwKeydown();? ? ? ? // Turn on sidetone, drive CW_KEY high to unbalance the modulator
?
? ? while (!tune_button_is_pressed) {? ?// Loop here till button is pressed again
? ? ? ? delay(100);? ? ? ? ? ? ? ? ? ? ?//? ?wait 100 milliseconds
? ? ? ? timer = timer+100;? ? ? ? ? ? ? //? ?count that new 100 milliseconds
? ? ? ? if (timer>15000) break;? ? ? ? ?//? ?abort the loop if 15 seconds have elapsed
? ? }
? ? delay(50);? ? ? ? ? // debounce for 50 milliseconds (needed if button is a mechanical switch)
?
? ? cwKeyUp();? ? ? ? ? // turn off sidetone and CW_KEY digital output
? ? stopTx();? ? ? ? ? ?// Return rig to receive mode
? }
##############################################################################



On Tue, Mar 12, 2019 at 08:11 AM, Ted wrote:
James,

Thanks. I really just need to try to learn.? After having tried to work with stepper motors and multiple PID sketches unsuccessfully, Arduino programming has left a bad taste in my mouth.

I envision a tab that will throw on a CW key up until pressed a second time, or time out in 15 seconds or so if not manually shut off.? Having two brothers who are programmers, I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

Ted
K3RTA


 

Ted K3RTA

I would second Jack's suggestion.? Read Beginning C for Arduino.? It is great.
There are also other Arduino C-language tutorials that are available with just? a
Google search.

Starting small is also a good idea.? Try one of the example code sections that
comes with the Arduino IDE.? Once you understand how this example works
it is easy to make incremental changes to that code to expand it to do additional
things.?

Arv? K7HKL
_._


On Tue, Mar 12, 2019 at 10:37 AM Jack Purdum via Groups.Io <jjpurdum=[email protected]> wrote:
I know of a pretty good book if you're interested!! Some research: Read the Amazon reviews on Beginning C for Arduino to see if it appears that the book meets your needs. Make sure you look at the 2nd edition. It has additional material plus a gentle introduction to C++ so you can kinda understand what's going on with libraries, almost all of which are written in C++.

Jack, W8TEE

On Tuesday, March 12, 2019, 11:11:13 AM EDT, Ted via Groups.Io <k3rta=[email protected]> wrote:


James,

Thanks. I really just need to try to learn.? After having tried to work with stepper motors and multiple PID sketches unsuccessfully, Arduino programming has left a bad taste in my mouth.

I envision a tab that will throw on a CW key up until pressed a second time, or time out in 15 seconds or so if not manually shut off.? Having two brothers who are programmers, I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

Ted
K3RTA


Jack Purdum
 

Jerry:

...I suggest you ignore all that C++ stuff...

Such a blanket statement is really not good advice, as it depends upon the way the topic is presented. My chapter on the intro to OOP/C++ is simply to understand what goes to the left of the dot operator and what goes to the right. Everyone has to figure out for themselves what:

?? Serial . print();

means at some point. If you have a clear explanation what an object is on the left of the dot operator and what a method or property is on the right, and can grasp what those things are, using an Arduino library properly becomes much easier. That's about as deep as I want to go with it in an intro C discussion. Ignoring something you use every time you write/modify a program just seems like bad advice to me.

Jack, W8TEE


On Tuesday, March 12, 2019, 1:03:59 PM EDT, Jerry Gaffke via Groups.Io <jgaffke@...> wrote:


Ted,

As a starting point, the code below should come close to doing what you want.
It has not been debugged.
And you will have to figure out how to implement? ?"tune_button_is_pressed"

Good to learn how to program a bit, and figuring out the Raduino is a very good place to start.
A good first program might be a stripped down thing that just writes to the LCD display.
And I suggest you ignore all that C++ stuff, concentrate on learning to program in vanilla C

Another bit of advice:?
Ignore all the subsequent posts from other forum denizens
regarding coding style and indentation and variable names and favorite programming languages
and how it was done back in the 1950's.? ;-)

An alternate way to implement this is to plug a straight key into the uBitx,? put a brick on it.? ? ;-)

Jerry, KE7ER


########################################################################
###########? ?Old code, near bottom of Farhan's ubitx_20.ino for the stock uBitx firmware:

void loop(){
? cwKeyer();
?

###############################################################
#################? New code, replace the old code with this:
?
void loop(){
? cwKeyer();
?
? if (tune_button_is_pressed) {
? ? short timer = 0;? ? // declare a 16 bit integer, initialize its value to zero
? ? delay(50);? ? ? ? ? // debounce for 50 milliseconds (needed if button is a mechanical switch)
?
? ? startTx(TX_CW);? ? ?// Put rig into CW transmit mode with CLK2 = transmit frequency
? ? cwKeydown();? ? ? ? // Turn on sidetone, drive CW_KEY high to unbalance the modulator
?
? ? while (!tune_button_is_pressed) {? ?// Loop here till button is pressed again
? ? ? ? delay(100);? ? ? ? ? ? ? ? ? ? ?//? ?wait 100 milliseconds
? ? ? ? timer = timer+100;? ? ? ? ? ? ? //? ?count that new 100 milliseconds
? ? ? ? if (timer>15000) break;? ? ? ? ?//? ?abort the loop if 15 seconds have elapsed
? ? }
? ? delay(50);? ? ? ? ? // debounce for 50 milliseconds (needed if button is a mechanical switch)
?
? ? cwKeyUp();? ? ? ? ? // turn off sidetone and CW_KEY digital output
? ? stopTx();? ? ? ? ? ?// Return rig to receive mode
? }
##############################################################################



On Tue, Mar 12, 2019 at 08:11 AM, Ted wrote:
James,

Thanks. I really just need to try to learn.? After having tried to work with stepper motors and multiple PID sketches unsuccessfully, Arduino programming has left a bad taste in my mouth.

I envision a tab that will throw on a CW key up until pressed a second time, or time out in 15 seconds or so if not manually shut off.? Having two brothers who are programmers, I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

Ted
K3RTA


 

I stand by my advice.

Yes, you do need to figure out a bit of C++ if you want to understand ArduinoLand libraries.
But you don't need to understand those libraries when starting out with programming under Arduino.
I have absolutely no use for the complications of C++ on a machine with 2k of RAM,?
it just gets in the way of figuring out how all the time/RAM/Flash has gotten eaten up.

That said, your book comes highly recommended.
And likely gives a good introduction to C++ for those so inclined.
Sounds like just about the right level of exposure.

Jerry



On Tue, Mar 12, 2019 at 10:34 AM, Jack Purdum wrote:
Jerry:
?
...I suggest you ignore all that C++ stuff...
?
Such a blanket statement is really not good advice, as it depends upon the way the topic is presented. My chapter on the intro to OOP/C++ is simply to understand what goes to the left of the dot operator and what goes to the right. Everyone has to figure out for themselves what:
?


 

Jack,

Yes, an Arduino programmer should understand that "Serial.print()" is trying to access the print() function in the Serial library.
But that will eventually sink in even if the new programmer did not read the above sentence.?

Ted said this:
>? I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

I suggest he start out by learning C.
If so inclined, he can then try out C++.?

Jerry



On Tue, Mar 12, 2019 at 12:21 PM, Jerry Gaffke wrote:
I stand by my advice.

Yes, you do need to figure out a bit of C++ if you want to understand ArduinoLand libraries.
But you don't need to understand those libraries when starting out with programming under Arduino.
I have absolutely no use for the complications of C++ on a machine with 2k of RAM,?
it just gets in the way of figuring out how all the time/RAM/Flash has gotten eaten up.

That said, your book comes highly recommended.
And likely gives a good introduction to C++ for those so inclined.
Sounds like just about the right level of exposure.

Jerry


Jack Purdum
 

Jerry:

Someone once said C is powerful enough to let you shoot yourself in the foot, but C++ has the power to blow your entire leg off. I think that's true. There are features in C++ that I rarely ever use (e.g., multiple inheritance) but there are concepts in OOP/C++ that can also be used in "straight" C, too. Perhaps the best pillar of the OOP Trilogy is Encapsulation. Simply stated, encapsulation means you hide the data. In C++, that means you hide the data in a class. In straight C, it means you avoid global variables. For those who may not know, global data is everywhere visible throughout the program and, hence, it can be changed by any statement in the program. If you define a variable within a function, you hide it from every statement outside that function. In C, a global variable is like placing a hooker at the top of your code and then giving a $100 bill to every statement in your program. If the program spawns a bug, you have very little idea which statement is the father of the bug. If you practice Encapsulation in your C programs, at least you know in which function the father is hiding.

About all the C++ I do in the book is explain what a class is and how its syntax manifests itself in an Arduino library. I don't really touch the complexities of C++ beyond that. Al (AC8GY) and I are writing a new book similar to my Arduino Projects for Amateur Radio, but we are also adding the Teensy and Blue Pill families of microcontrollers. Because of the expanded resources of those processors (e.g., the Teensy has 256K of SRAM and 1Mb of flash, all clocked at 180MHz), that book spends a little more time discussing C++, but does not dig that much deeper into it. You can do some serious programming with these additional processors. (Our JackAl project has over 11,000 lines of source code spread over 19 project files!)? I felt the expansion was necessary because I wrote some of my own class libraries for the projects.

Anyway, perhaps our viewpoints differ on the word "understand". I don't expect someone who is just starting out with an Arduino project to jump in and start writing class libraries. However, I do feel they need to understand what the Serial object brings to the table for them, especially for debugging purposes. In the Beginning C book, the title for Chapter 14 was selected with considerable care: A Gentle Introduction to Object Oriented Programming and C++, and I sincerely believe that's what it is...useful, but gentle.

Jack, W8TEE



On Tuesday, March 12, 2019, 3:21:06 PM EDT, Jerry Gaffke via Groups.Io <jgaffke@...> wrote:


I stand by my advice.

Yes, you do need to figure out a bit of C++ if you want to understand ArduinoLand libraries.
But you don't need to understand those libraries when starting out with programming under Arduino.
I have absolutely no use for the complications of C++ on a machine with 2k of RAM,?
it just gets in the way of figuring out how all the time/RAM/Flash has gotten eaten up.

That said, your book comes highly recommended.
And likely gives a good introduction to C++ for those so inclined.
Sounds like just about the right level of exposure.

Jerry



On Tue, Mar 12, 2019 at 10:34 AM, Jack Purdum wrote:
Jerry:
?
...I suggest you ignore all that C++ stuff...
?
Such a blanket statement is really not good advice, as it depends upon the way the topic is presented. My chapter on the intro to OOP/C++ is simply to understand what goes to the left of the dot operator and what goes to the right. Everyone has to figure out for themselves what:
?


Jack Purdum
 

Agree. That's why the OOP/C++ stuff is in the last chapter of the book.

Jack, W8TEE

On Tuesday, March 12, 2019, 3:31:18 PM EDT, Jerry Gaffke via Groups.Io <jgaffke@...> wrote:


Jack,

Yes, an Arduino programmer should understand that "Serial.print()" is trying to access the print() function in the Serial library.
But that will eventually sink in even if the new programmer did not read the above sentence.?

Ted said this:
>? I kind of understand the logic involved or likely involved; getting to know C++ would be interesting.

I suggest he start out by learning C.
If so inclined, he can then try out C++.?


Jerry



On Tue, Mar 12, 2019 at 12:21 PM, Jerry Gaffke wrote:
I stand by my advice.

Yes, you do need to figure out a bit of C++ if you want to understand ArduinoLand libraries.
But you don't need to understand those libraries when starting out with programming under Arduino.
I have absolutely no use for the complications of C++ on a machine with 2k of RAM,?
it just gets in the way of figuring out how all the time/RAM/Flash has gotten eaten up.

That said, your book comes highly recommended.
And likely gives a good introduction to C++ for those so inclined.
Sounds like just about the right level of exposure.

Jerry