diff --git a/README.md b/README.md new file mode 100644 index 0000000..9e418e1 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# sBitx + +This is the Github source repository for the HFSignals sBitx models. + +https://www.hfsignals.com/index.php/sbitx-v2/ + +The sBitx is an open source, high performance Hybrid SDR for the 21st +century radio amateurs. Powered by an internal Raspberry Pi 4, it has +CW/RTTY/PSK31/SSB and FT8 with logging software, macros, spotting built-in. + +!["sBitx v2"](https://www.hfsignals.com/wp-content/uploads/2023/04/sbitxv2hero3.jpg) + + +## Important documentation + +* Getting Started (Hello v2) [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/hellov2.md)] [[PDF](https://github.com/afarhan/sbitx/blob/main/doc/pdf/hellov2.pdf)] +* Install [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/install.md)] +* Commands [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/commands.md)] +* How the GUI is organized [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/how_gui_is_organized.md)] +* UI Notes [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/ui_notes.md)] +* WSJT-X Notes [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/wsjtx_notes.md)] +* Coding Convention [[Markdown](https://github.com/afarhan/sbitx/blob/main/doc/coding_convention.md)] + +## Hardware Schematics +* sBitx Digital [[PDF](https://github.com/afarhan/sbitx/blob/main/doc/pdf/sbitx_digital.pdf)] +* sBitx Main [[PDF](https://github.com/afarhan/sbitx/blob/main/doc/pdf/sbitx_main.pdf)] +* sBitx v2 Circuit [[PDF](https://github.com/afarhan/sbitx/blob/main/doc/pdf/sbitxv2_circuit.pdf)] + +## Community mailing list +https://groups.io/g/bitx20 + diff --git a/coding_convention.txt b/doc/coding_convention.md similarity index 95% rename from coding_convention.txt rename to doc/coding_convention.md index f014863..2f9e9f6 100644 --- a/coding_convention.txt +++ b/doc/coding_convention.md @@ -1,6 +1,8 @@ +# Coding Convention + This is a short note on the coding conventions followed with the source code of sbitx. -1. The source code files should be formatted so that they don't go paste the right edge of the +1. The source code files should be formatted so that they don't go past the right edge of the screen on the 800x480 display of the Raspberry Pi. 2. For function and variable names, we use all small case with underscore (_) to seperate out diff --git a/commands.txt b/doc/commands.md similarity index 67% rename from commands.txt rename to doc/commands.md index 8351ec8..849db89 100644 --- a/commands.txt +++ b/doc/commands.md @@ -1,40 +1,46 @@ -These are text commands that can be entered from the keyboard -\callsign [callsign] +# Commands + +These are text commands that can be entered from the keyboard: +- `\callsign [callsign]` Sets your callsign to the following string. -\grid [grid] + +- `\grid [grid]` Sets your grid (six letters) that is used in FT8 and other modes to indicate your approximate locationi. -\freq [frequency in Hz or Kilohertz] + +- `\freq [frequency in Hz or Kilohertz]` You can also type just 'f' instead 'freq' if you the type '\f 7050' it will set be the same as '\freq 7050000' -\cwdelay [100-2000] msec. How long radio remains in transmit in CW before - timing out to rx. ex: "\cwdelay 500" -\cwinput [key\keyer\kbd] + +- `\cwdelay [100-2000]` + How long radio remains in transmit in CW before timing out to rx in ms. ex: "\cwdelay 500" + +- `\cwinput [key\keyer\kbd]` Chooses the CW input method between straight key(key), Iambic keyer(keyer) and the keyboard (kbd). -\mode [USB\LSB\etc..]... + +- `\mode [USB\LSB\etc..]` Chooses from the modes available in the mode selection control. You can use 'm' instead of 'mode' -\t + +- `\t` Puts the radio into transmit. You can also use Ctrl-T -\r + +- `\r` Puts the radio into receive. You can also use Ctrl-R -\topen [server]:[port] + +- `\topen [server]:[port]` Opens a telnet session with an RBN or a DX cluster telnet server. It works with ip address as well as domain names Ex: \topen dxc.g3lrs.org.ul:7300 -\tclose + +- `\tclose` Closes the existing telnet session -\w [telnet command string] + +- `\w [telnet command string]` Writes the remaining text (skipping the space after '\w') to the currently opened telnet server -\txpitch [in Hz] + +- `\txpitch [in Hz]` Sets the tone of transmit tone of the CW. Ex: \txpitch 700 -\ - - - - - - diff --git a/doc/hellov2.md b/doc/hellov2.md new file mode 100644 index 0000000..0e317c6 --- /dev/null +++ b/doc/hellov2.md @@ -0,0 +1,461 @@ +# Hello, + +This is a quick guide to using the sBitx v2 radio. The radio is under +constant development and the latest version of this guide will be +available on https://github.com/afarhan/sbitx/doc/hellov2.md. + +The sBitx v2 is the evolution of the development edition launched in 2022. As a software defined radio should be, expect constant changes +to the user interface. This document will be constantly revised to reflect +the changes in the user interface, newer modes, etc. The latest version +of this manual as well as the software will always be available on +https://github/com/afarhan/sbitx. + +Unlike other closed source and proprietary radios, the sBitx is entirely +open source, from its circuits to the software. HF Signals happens to +be just a company that commercially produces kits and board based on +the bitx designs. Others are invited to produce their own version of +sbitx and sell them as long as their derived work remains open source +as well. + +### Acknowledgements + +As is with most science and free software, this work builds on previous +works. In particular, I am grateful to Phil Karn, KA9Q for pointing me to +convolution method of SDR, Bob Larkin, W7PUA, for his seminal paper +describing the DSP-10 SDR which was the architecture we have followed with sBitx and Wes, W7ZOI for being the elmer and direct +contributor to so many circuit blocks used here. + +Hans, G0UPL, probably invented the LPF switching using the1N4007s +that makes this such a silent radio, Don, W6JL built the first power +amplifier with IRFZ24N and we built upon his work as well as his +detailed study of using the 1N4007s as RF switches. + +These are all direct contributors to the sBitx. + +Finally, the amazing bunch at bitx20@groups.io that kept the flame +burning with unstable development journey and hung on till the end. +They made numerous contributions including the fixes to the PA by +Allison, patches by Anthony and many other contributors, This is the as +beautiful as a collaborative free software project gets, + +### A Different Beast + +Expect the sbitx to be a different radio from the ones that you are used +to. + +- **Where did it go?** The user interface is dynamic so you won’t +see all the controls all the time. When operating SSB, you won't’ +see a control to set CW sending speed and when operating +CW, you won’t see the mic gain. + +- **It is HTML.** The user interface is written in HTML which was +designed for documents, not radio. However, it is our best bet +as it will be so easy to change the user interface with rudimentary HTML, javascript and CSS skills. Read the chapter +on hacking the sbitx. + +- **Four wheels are enough**. Just like adding two more wheels to +a four wheeler doesn’t radically improve performance unless +you are going to Mars in a rover. Similarly, there is enough +performance in the sBitx for most of your work. Where it excels +is how easy it is to use the radio and concentrate on operating +rather than getting lost in confusing controls. + +- **Ask for help**. These are early days for integrated radios, we +will all learn from this process. Join the bitx20@groups.io and +ask questions. + + +## Setting up the sBitx + +### Antenna + +The sBitx can withstand up to 2.0 SWR of antenna mismatch. It is best to use a well matched antenna that keeps the SWR below 1.5 for best results. + +### Powering up the radio. + +You will need a low noise power supply rated for 12 to 13.8v capable of +delivering at least 10 A of current. At HF Signals, we use a meanwell +model LRS-150-12. This is no official endorsement but just comment +on the kind of power supply we use, We crank up the voltage with the +small preset on the power supply to give us about 13.5V of voltage. + +The power connector on the sBitx is an XT60. This is now a common +high amperage connector popular among the drone and r/c flyers. You +will get a mating connector for this in your kit that can be soldered to +any other kind of connector you may have on your power supply. + +!["XT60 image"](images/hellov2-000.jpg) + +!["Raspberry Pi Desktop"](images/hellov2-001.jpg) + +Upon switching your radio, in a few seconds, the raspberry pi desktop +will appear. Touch the sbitx icon to launch the radio. + +!["Web Login"](images/hellov2-003.jpg) + +The sBitx application will launch the browser. You will need to type in +the passkey. The initial passkey is “123”. You can use the on-screen +keyboard to type it in or use an attached physical keyboard. Press `Start` + +!["Web User Settings"](images/hellov2-004.jpg) + + +As a first time user, you have to add some basic information to your +radio. + +- Press on the `Settings` button on the left column to open the +Settings Panel +- Enter your callsign and grid location (use the onscreen +keyboard or a plugged-in physical keyboard) +- Press `Update` + +Your radio is now configured for all modes. + +## Basic Operations + +!["Web Controls"](images/hellov2-005.jpg) + +### Common controls + +The controls column is on the left. Only the basic controls are visible on +all modes. In the column. If you scroll down the display, you will see +more items on the left column. + +The controls work with the function knob (the physical knob on the top +right corner of the sbitx) as well as on screen. + +For instance, when you select the VOL(Volume) control with your finger +or mouse, you can use the function knob to change the setting as well +as drag it on the screen to a new loudness. + +**Frequency Display.** This is on the top left of the screen. It shows the +frequency of operation, if your RIT or SPLIT has been switched on, +current AGC and bandwidth settings. Clicking/Touching on this will +open up more controls that are explained in the next section. + +- **Mode** switches between various modes like CW/SSB/FT8, +etc. +- There are many ways to tune your sBitx. You can use the +physical knob or you can use the on-screen tuning dial to spin +around. The tuning rate is set by the STEP control located right +beneath the on-screen tuning dial. +- **RF** Gain should be kept to a point where you can barely see +the band noise level above the base-line. This provides the best +audio. + +- The frequency on the dial corresponds to the centerline of the +spectrum and waterfall. The gray strip shows the current +listening bandwidth. + +- **UTC time**. The current UTC time is display on the top center. + +- **The double arrow icon** is always on the top right corner. if +you click it once, the SDR window will become a regular +browser window and allow you to switch to other applications +and software, clicking on it again will return the sBitx window to +full screen. + +- TX **Drive** Just under the on-screen tuning dial there is TX drive +control to control the transmit drive from 1 to 100. Note that this +control is drive and it is not the reading of power in watts. The +exact power in watts will show on the transmit meters when +transmitting. + +You will note that many controls such as bandwidth, AGC, etc. are +missing from the left column. These are accessed in a hidden panel by +touching on the frequency display: + +!["Additional Web Controls"](images/hellov2-006.jpg) + +### Band stacked VFOs + +There are four frequency memories on each band, this is called band +stacking. By clicking on each band switch repeatedly, you will cycle +through each of them. When you stay on a particular frequency and +tune around, the band stack is updated to that frequency. It is more +intuitive to just use it rather than read about it. + + +### RIT + +The usual RIT feature is available. The RIT tuning range is restricted to +25 KHz from the transmit frequency. For larger splits, use the SPLIT +function discussed below. + +### VFOs A & B + +Two VFOs are available to allow you to work split, or just remember +one frequency and quickly check on another. Each of the two VFO +buttons switch to the VFO A or B. + +### Split Operating + +Frequently, while DXing or Contesting, the operation is split to different +frequency for transmit and receive. Though RIT can be used for this, a +better option is to set the VFO A to the transmitting frequency and use +the VFO B to listen. + +- Turn on the SPLIT by touching the **SPLIT** button. Now, VFO A +will be your transmitting frequency and VFO B will be your +listening frequency. + +- The A and B frequencies may be really away from each other. +You can set them to the current frequency on display by +touching on **A=B** button. + +- At times you may want to swap the transmitting and receiving +frequencies. This is done with the **A<>B** button. + +### Filters + +There are nine prebuilt filters available to choose from. On modes like +CW/RTTY/PSK31, the filters will center around the PITCH frequency +which is used to transmit as well as decode. More about the PITCH +control on the CW section. + +For pesky QRM from stations close to your contact’s frequency, you +may use the manual HIGH and LOW control to move the bandwidth +around to eliminate the QRM manually. + +#### Tip: Choosing a bandwidth + +Having a very narrow filter, let’s say 200 Hz while tuning around with a +step of 1 KHz will result in missing many signals. Keep a check on your +tuning rate when using a narrow filter. + +Usually, when hunting for stations, it is a good idea to keep the +bandwidth of the filter wide. + +A width of 1.5 KHz is recommended for CW and other data modes +while 2.4 KHz is a good choice for SSB work. + +Once a station is located, center it inside the bandwidth strip on the +spectrum for best decoding and pleasing audio. + + +## Logging and the Logbook + +!["Web Logbook"](images/hellov2-007.jpg) + +sBitx has a simple logger, those used to the N1MM logger will find this +familiar. + +The top line of the logger has a series of empty boxes. + +- **Entering a QSO.** You enter the contact’s callsign in the first +box, the received signal and the sent signal in the first three +boxes. The other two are used only during contests, they will be +explained elsewhere. +When the first three boxes are filled, you can press the LOG +button to enter the QSO into the logbook. + +- **View Log** Press the Logbook button to view the logbook, The +logbook can be closed by pressing the x close button on the +top right of the logbook panel. + +Press the Load button to load more QSOs in the logbook. It +loads only the last 50 in the beginning. + +- **Search the Logbook.** Enter the callsign or part of the callsign +to search and press the Search button. To go back to the full +logbook, Press Load. + +### Macros + +Macros add a lot of fun, ease and speed to your CW/RTTY/PSK +operations. They work with the contact’s callsign and reports you have +entered in the logger entry boxes show on top of the picture above. + +The macros are available on function keys of any attached keyboard, +they can also be used by pressing the macro buttons. You can have a +maximum of 12 macros defined. These are stored in text files with .mc +extension the directory `/home/pi/sbitx/web`. You can view and edit +them. It is recommended that instead of editing them directly, you +should make a copy and give it a new name, keeping the extension +to `.mc`. + + +- All the macro files available are listed in the dropbox next to the +macro buttons. You can choose a different macro file +depending upon what kind of operating you want to do. + +- The macros will substitute your callsign, grid, the contact’s filled +in callsign, report (from the logger boxes). + +This is best explained with an example. Choose CW1 from the drop +list. Now, + + +- **F1 CQ**. This will call CQ with your callsign as it was entered in +the settings panel + +- **F2 Replay**. First fill the contact’s callsign and their signal +report, then pressing this will generate a message that is reply +to the contact with your callsign, etc. In the above case, it will +be generate the message: + +``` +rr VU2XZ de VU2ESE. ur rst599 599. tnx fer qso. +hw cpy? VU2XZ de VU2ESE kn +``` + +(Here the sbitx operator’s callsign is assumed to be VU2ESE, +the contact’s callsign and report were picked up from the logger +window). + +- **Log** When the QSO is confirmed, you can press the **Log** +button and the logbook will be updated. + +- **Wipe** You can clear the logger window without having the +delete individual entry boxes by pressing the **Wipe** button. + +- **Esc** You can interpret a transmission of a macro generated +message by pressing the Esc button or pressing the Escape +key on the physical keyboard. + + +## CW + +The sBitx is a great CW machine. It has some amazing features for the +CW operator + + +- CW filters from 100 Hz to 3 KHz with minimum ringing +- Noiseless, electronic T/R and band switching with diodes. +- Fldigi’s CW decoder works in the background +- Intersperse paddle/straight key sending with keyboard and +macros +- Integrated logger with macros to generate common messages. + +!["Web CW Display"](images/hellov2-008.jpg) + +- Using the decoder is easy, just tune the interesting signal +exactly onto the pitch line +- The CW PITCH control sets your sending and receiving pitch. +- Use narrow filters to cut out the band noise and QRM + +- With narrow filters, when hunting stations, use 100 Hz or 10 Hz +tuning rate and keep the span to 10K or less + +- In addition to the paddle or straight key, you can also transmit +CW from the on-screen keyboard an attached physical +keyboard. + +- Learn to use macros, they save effort (see Logging and the +Logbook section) + + +## SSB + +!["Web SSB Display"](images/hellov2-009.jpg) + +The sBitx kit comes with an in-built as well as a handheld mic. The +3.5mm audio jack connector can take any normal microphone that +doesn’t have a PTT button too. The on-screen buttons can substitute +for the PTT. + +Note that instead of one PTT button there are separate buttons to start +transmission and to go back to listening. This is done so that your +hands are free to write down things, tune the antenna, type the +callsigns into the logger, etc. + + +- Choose a bandwidth greater than 1.5 K, 2.4 KHz is a good +bandwidth for voice +- The mic gain with the supplied hand-held microphone should be +24 or 25. +- When using the internal mic, increase the mic gain to 50. + +## FT8 + +!["Web FT8 Display"](images/hellov2-010.jpg) + +FT8 is considered to be tough to set up with a regular radio and a +computer. However, with sbitx, it is very easy. Here is how: + + +- Tune to the FT8 frequency, set the bandwidth to 3 KHz and +listen for a while watching the waterfall for spots where no one +is transmitting. +- Move the **Tx Freq** using the slider until the tx line on the +spectrum is positioned at a relatively unoccupied frequency. +- The left window shows the band activity. Click on any +interesting callsign calling CQ to begin the call. Sit back and +watch sbitx complete it for you. The logger window will +automatically fill the callsign and signal reports +- To call CQ, press the **Call CQ** button and the CQ will start at +the next cycle. + + +#### Time synchronization + +The FT8 relies on starting the transmission/reception at every 15 +second boundary. It is vital that the sbitx Real-time clock is properly +synchronized. The RTC synchronizes itself using the NTP to within a +few milliseconds each time there is Internet connectivity. + +To maintain proper time, connect the sbitx to the Internet through Wifi +or Ethernet and reboot and run sbitx. The correct UTC time should +automatically display at the top. + + +## RTTY/PSK31 + +!["Web RTTY/PSK31 Display"](images/hellov2-011.jpg) + +The RTTY and PSK31 modes of sBitx are implemented using fldigi that +runs in the background. + + +- Align the signal being received to the RX pitch line on the +window +- Press TX button and start typing to transmit +- Press RX button to end the transmission +- As in CW, you can use the Macros to send standard messages + +## DX Spotting, Clusters + +Many hams enjoy exchanging messages to each other over the +internet about the stations they are spotting on the band. This helps +you hunt for specific DX stations or to find out the activity in general. + +These stations use telnet to get the stream of these messages. + +You will need to have sbitx online to use this. + +!["Web DX Spotting"](images/hellov2-012.jpg) + +- Choose Telnet from the left column to open the telnet panel. +- Press **Start** button to start streaming messages. +- A ticker tape of the latest spots near your operating frequency +will stream under the spectrum. +- You can enter the dx cluster commands in the edit window of +the telnet panel. Each server has a different set of commands. + +You can set your dx cluster server through the Settings panel. + +If you are interested in learning more about dx clusters, etc. Find the +information on the Internet, including commands to filter the spots, etc. + +This version of sbitx does not support sending your spots to the cluster +network yet. + +## Audio Recorder + +It is good to be able to record some brag tapes of rare or important +contacts. The recorder with sBitx will place all the recorded files in +`/home/pi/sbitx/audio`. Each audio file is named by the time at which it +was recorded. + +Using the recorder is easy. + +!["Web Audio Recorder"](images/hellov2-013.jpg) + +- Open the recorder by pressing on the Recorder button in the +left column. +- Press Record button to start recording +- Press Stop to stop recording + +To retrieve / play the recordings, you will have to switch from sBitx to +other raspberry pi applications (like the file manager) to view and play +the files. diff --git a/how_gui_is_organized.txt b/doc/how_gui_is_organized.md similarity index 65% rename from how_gui_is_organized.txt rename to doc/how_gui_is_organized.md index 8b46df4..759f57f 100644 --- a/how_gui_is_organized.txt +++ b/doc/how_gui_is_organized.md @@ -1,4 +1,4 @@ -***How the GUI works +# How the GUI works This is a brief explanation of how the GUI works for now, it may evolve and change later. I wrote the GUI for those who don't have the time to sit down @@ -15,13 +15,13 @@ particular colour and lined with a border colour. 4. Detect touch/mouse and report where it has clicked,scrolled on the screen. 5. Read the keyboard strokes like up and down, etc. -These routines are ui_init(), draw_text(), measure_text() (how many pixels -wide will a particular string be on the screen for a given font?), rect() and -fill_rect(). +These routines are `ui_init()`, `draw_text()`, `measure_text()` (how many pixels +wide will a particular string be on the screen for a given font?), `rect()` and +`fill_rect()`. Additionally we provide mouse, keyboard and timer tick events through -on_key_press(), on_key_release(), on_scroll() and on_mouse_press() events. -The routine to re-draw the entire screen is on_draw_event(). These are the only +`on_key_press()`, `on_key_release()`, `on_scroll()` and on_mouse_press() events. +The routine to re-draw the entire screen is `on_draw_event()`. These are the only GUI specific functions. Each control is selected by touching it from the display and either turning @@ -29,11 +29,12 @@ the function encoder, using up and down keys or the mouse scroll wheel. Once of the reasons to build our own GUI was that we needed the GUI to work with the encoders on the front-panel. -** A simple GUI ** +## A simple GUI We make our own GUI with just one kind of control (called widgets by some user interface toolkits) : this is as follows: - + +```c++ struct field { char *cmd; int x, y, width, height; @@ -45,51 +46,52 @@ We make our own GUI with just one kind of control char selection[1000]; int min, max, step; }; +``` Each field occupies a rectangle specified by x,y,width and height with reference to top left corner of the window as the 0,0 position. Each field can optionally have a label (like "IF Gain") and the current value is stored as a string in the value[] field. -The field is drawn by calling the draw_field() function. It uses the the font -given by the index number font_index from the font_table[] array. +The field is drawn by calling the `draw_field()` function. It uses the the font +given by the index number `font_index` from the `font_table[]` array. This saves having to specify all the font details for each field separately. -If you want to change the font for all the controls, edit the font_table[]. +If you want to change the font for all the controls, edit the `font_table[]`. The field control can be of several types as identified by value_type field: - NUMBER: like the frequency, gain, volume, etc. The upper and lower - limit for the number field is set by min, max. Step determines how - much it changes by with each scroll/up-down keystroke. +- NUMBER: like the frequency, gain, volume, etc. The upper and lower +limit for the number field is set by min, max. Step determines how +much it changes by with each scroll/up-down keystroke. - SELECTION: This uses a number of strings separated by '/' stored in - selection[] field. One of the strings is selected by scroll through - the field's values. Ex: Mode: USB/LSB/CW/CWR/DIGITAL, etc. +- SELECTION: This uses a number of strings separated by '/' stored in +selection[] field. One of the strings is selected by scroll through +the field's values. Ex: Mode: USB/LSB/CW/CWR/DIGITAL, etc. - TEXT: This is makes it an editable text field (for instance to enter - your callsign). +- TEXT: This is makes it an editable text field (for instance to enter +your callsign). - TOGGLE: This kind of button is either ON or OFF (it could very well be - done using SELECTION with just two choices) +- TOGGLE: This kind of button is either ON or OFF (it could very well be +done using SELECTION with just two choices) - BUTTON: The button control is used to trigger something on as long - as it is held down and then it switches off again (CW key, PTT, Tune) +- BUTTON: The button control is used to trigger something on as long +as it is held down and then it switches off again (CW key, PTT, Tune) Finally, the cmd field is an interesting field and it goes more than what meets the eye. Lets imagine that the cmd is set to "freq" and the field type is NUMBER, set to max of 7300,000 and min of 7000,000 with a step of 10. Now, this field can be used to tune the radio up and down the 40 meter band in -steps of 10 Hz. Each time the value is changed, the function do_cmd() is called +steps of 10 Hz. Each time the value is changed, the function `do_cmd()` is called with both the field name and the value in the same string, separated -by an equal ('=') sign. Like do_cmd("freq=7000000"). +by an equal ('=') sign. Like `do_cmd("freq=7000000")`. We did this so that most of the commands can be directly passed the the core -sdr by calling sdr_request() in sbitx.c. However, there are certain features -that are not in the core sdr like band-switched VFOs, keyer, etc. The cmd[] +sdr by calling `sdr_request()` in `sbitx.c`. However, there are certain features +that are not in the core sdr like band-switched VFOs, keyer, etc. The `cmd[]` fields for these controls have a '#' character in the cmd field. Like "#wpm=12" to set the keyer speed to 12 wpm. -The commands generated by the controls are all filtered through do_cmd() in a +The commands generated by the controls are all filtered through `do_cmd()` in a large if-then-else logic, table driven despatch may be efficient but less readable for the beginning programmer. \ No newline at end of file diff --git a/doc/images/hellov2-000.jpg b/doc/images/hellov2-000.jpg new file mode 100644 index 0000000..842ba70 Binary files /dev/null and b/doc/images/hellov2-000.jpg differ diff --git a/doc/images/hellov2-001.jpg b/doc/images/hellov2-001.jpg new file mode 100644 index 0000000..de10817 Binary files /dev/null and b/doc/images/hellov2-001.jpg differ diff --git a/doc/images/hellov2-003.jpg b/doc/images/hellov2-003.jpg new file mode 100644 index 0000000..24a0a6a Binary files /dev/null and b/doc/images/hellov2-003.jpg differ diff --git a/doc/images/hellov2-004.jpg b/doc/images/hellov2-004.jpg new file mode 100644 index 0000000..88c2710 Binary files /dev/null and b/doc/images/hellov2-004.jpg differ diff --git a/doc/images/hellov2-005.jpg b/doc/images/hellov2-005.jpg new file mode 100644 index 0000000..ff1464e Binary files /dev/null and b/doc/images/hellov2-005.jpg differ diff --git a/doc/images/hellov2-006.jpg b/doc/images/hellov2-006.jpg new file mode 100644 index 0000000..89c5951 Binary files /dev/null and b/doc/images/hellov2-006.jpg differ diff --git a/doc/images/hellov2-007.jpg b/doc/images/hellov2-007.jpg new file mode 100644 index 0000000..a81a5b0 Binary files /dev/null and b/doc/images/hellov2-007.jpg differ diff --git a/doc/images/hellov2-008.jpg b/doc/images/hellov2-008.jpg new file mode 100644 index 0000000..ddad890 Binary files /dev/null and b/doc/images/hellov2-008.jpg differ diff --git a/doc/images/hellov2-009.jpg b/doc/images/hellov2-009.jpg new file mode 100644 index 0000000..25a1122 Binary files /dev/null and b/doc/images/hellov2-009.jpg differ diff --git a/doc/images/hellov2-010.jpg b/doc/images/hellov2-010.jpg new file mode 100644 index 0000000..c4b510b Binary files /dev/null and b/doc/images/hellov2-010.jpg differ diff --git a/doc/images/hellov2-011.jpg b/doc/images/hellov2-011.jpg new file mode 100644 index 0000000..ace4c68 Binary files /dev/null and b/doc/images/hellov2-011.jpg differ diff --git a/doc/images/hellov2-012.jpg b/doc/images/hellov2-012.jpg new file mode 100644 index 0000000..01f608e Binary files /dev/null and b/doc/images/hellov2-012.jpg differ diff --git a/doc/images/hellov2-013.jpg b/doc/images/hellov2-013.jpg new file mode 100644 index 0000000..80954a2 Binary files /dev/null and b/doc/images/hellov2-013.jpg differ diff --git a/install.txt b/doc/install.md similarity index 74% rename from install.txt rename to doc/install.md index e724e05..e91a3f7 100644 --- a/install.txt +++ b/doc/install.md @@ -1,20 +1,24 @@ -##Step 1: UPDATE wiringPi. +## Step 1: UPDATE wiringPi. wiringPi is the arduino like library that allows you to flip digital lines on the GPIO connector and read them. We use this library as it is easy to use for those who have the experience with Arduino programming. - cd /tmp - wget https://project-downloads.drogon.net/wiringpi-latest.deb - sudo dpkg -i wiringpi-latest.deb +``` +cd /tmp +wget https://project-downloads.drogon.net/wiringpi-latest.deb +sudo dpkg -i wiringpi-latest.deb +``` -##Step 2: INSTALL ncurses +## Step 2: INSTALL ncurses From the command line terminal, run: - sudo apt-get install ncurses-dev +``` +sudo apt-get install ncurses-dev +``` -##Step 3: INSTALLING FFTW3 +## Step 3: INSTALLING FFTW3 We use the excellent FFTW3 library to do all our Fourier Transforms, this library is central to our SDR work. @@ -22,29 +26,37 @@ to our SDR work. Innstall fftw3 from the tarball downloaded from www.fftw.org, follow the instructions for the config, make. run make install as sudo - ./configure - make - sudo make install +``` +./configure +make +sudo make install +``` You have to run the same process once more for installation of the single precision float library. - ./configure --enable-float - make - sudo make install +``` +./configure --enable-float +make +sudo make install +``` -##Step 4: Some required standard libraries +## Step 4: Some required standard libraries - sudo apt-get install libasound2-dev - sudo apt-get install libgtk-3-dev - sudo apt-get install libgtk+-3-dev +``` +sudo apt-get install libasound2-dev +sudo apt-get install libgtk-3-dev +sudo apt-get install libgtk+-3-dev +``` -##Step 5: INSTALLING LOOPBACK +## Step 5: INSTALLING LOOPBACK IMPORTANT: pulseaudio maybe taking over ALSA sound system that sbitx runs on edit /etc/pulse/client.conf and add the line - autospawn = no +``` +autospawn = no +``` to disable it. @@ -67,27 +79,34 @@ To pick up the modulating audio generated by wsjtx (or other external programs), device of the external program should be set to hw:2,0 and the sbitx will capture back the transmitting audio from hw:2,1. Again, hw:2,0 and hw:2,1 are operating as second pair. - SBITX Audio WSJT-X Audio - hw:0,0 -> Speaker - hw:0,0 <- Mic - - hw:1,0 -> Line out ----> hw:1,1 Mic In / Capture - hw:2,1 <- Line In ------ hw:2,0 Speaker +| SBITX Audio | WSJT-X Audio | +|------------------------|-------------------------| +| hw:0,0 -> Speaker | | +| hw:0,0 <- Mic | | +| hw:1,0 -> Line out -> | hw:1,1 Mic In / Capture | +| hw:2,1 <- Line In -- | hw:2,0 Speaker | + To temporarily enable the loopback, you have to run this command from the command line: - sudo modprobe snd-aloop enable=1,1,1 index=1,2,3 +``` +sudo modprobe snd-aloop enable=1,1,1 index=1,2,3 +``` You can check that the three loopback devices are working by running the command : - aplay -l +``` +aplay -l +``` The sbitx will not work if the loopback is not present. You can automatically run snd-aloop upon booting up by adding this line to /etc/rc.local - sudo modprobe snd-aloop enable=1,1,1 index=1,2,3 +``` +sudo modprobe snd-aloop enable=1,1,1 index=1,2,3 +``` -##Step 6: +## Step 6: EDITING THE config.txt @@ -96,61 +115,77 @@ or vi from the terminal. This file is used to configure the Raspberry Pi as it i add these lines to the very end of the /boot/config.txt - gpio=4,17,27,22,10,9,11,5,6,13,26,16,12,7,8,25,24=ip,pu - gpio=24,23=op,pu +``` +gpio=4,17,27,22,10,9,11,5,6,13,26,16,12,7,8,25,24=ip,pu +gpio=24,23=op,pu - #Disable under-voltage warning - avoid_warnings=1 - dtoverlay=audioinjector-wm8731-audio +#Disable under-voltage warning +avoid_warnings=1 +dtoverlay=audioinjector-wm8731-audio +``` You also have to disable the built-in audio system, locoate the line that says dtparam=audio=on and add a '#' character before it to disable it - #dtparam=audio=on - +``` +#dtparam=audio=on +``` -##STEP 7: SUPPRESS THE LOW VOLTAGE WARNINGS +## STEP 7: SUPPRESS THE LOW VOLTAGE WARNINGS The Raspberry Pi has some issue when powered from the GPIO pins instead of the USB power port. It keeps complaining about low power (although we supply it 5.5V). To keep the Low voltage warnings from popping up all the time, from the commaind line run: - sudo apt remove lxplug-ptbatt - +``` +sudo apt remove lxplug-ptbatt +``` -##STEP 8: Install ntpstat +## STEP 8: Install ntpstat ntp and ntpstat are useful to know if the radio is synched to realtime. this is important when the date/time in the logbook needs to be accruate. it is also useful for ft8 synchronization +``` sudo apt install ntp sudo apt install ntpstat +``` ## step 9: the webserver of sbitx runs on port 8080 this has to redirect to port 80. To do this... + +``` sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080 +``` and then, install iptables-persistent (so it saves the current iptables) + +``` sudo apt-get install iptables-persistent --fix-missing +``` ## step 10: to make your sbitx appear as sbitx.local on the local network copy the files hosts and hostname to etc under sudo +``` sudo cp hosts /etc/hosts sudo cp hostname /etc/hostname +``` ## step 11: create a fresh logbook database in the data subdirectory you may have to install sqlite3 first +``` sudo apt update sudo apt install sqlite3 sudo apt install libsqlite3-dev cd data sqlite3 < create_db.sql +``` -##step desktop short-cut +## step 12: desktop short-cut this doesnt work with touch as it needs double click fro Accessories->File Manager, from edit menu go to preferences and in the general tab turn on diff --git a/hellov2.pdf b/doc/pdf/hellov2.pdf similarity index 100% rename from hellov2.pdf rename to doc/pdf/hellov2.pdf diff --git a/sbitx_digital.pdf b/doc/pdf/sbitx_digital.pdf similarity index 100% rename from sbitx_digital.pdf rename to doc/pdf/sbitx_digital.pdf diff --git a/sbitx_main.pdf b/doc/pdf/sbitx_main.pdf similarity index 100% rename from sbitx_main.pdf rename to doc/pdf/sbitx_main.pdf diff --git a/sbitxv2_circuit.pdf b/doc/pdf/sbitxv2_circuit.pdf similarity index 100% rename from sbitxv2_circuit.pdf rename to doc/pdf/sbitxv2_circuit.pdf diff --git a/doc/ui_notes.md b/doc/ui_notes.md new file mode 100644 index 0000000..c3c4948 --- /dev/null +++ b/doc/ui_notes.md @@ -0,0 +1,48 @@ +# UI Notes + +The sbitx is hackable in various ways. Writing newer and better user interfaces +is one way to make it better.This is a short note to explain how it the current +gui written in gtk works. + +## UI +The user interface for a radio is an interesting challenge. It has to work with knobs and buttons as well as a pointer and keyboard. This gtk user interface works with five hardware buttons and two encoders. We use the GTK library to gain access to a screen where we do all the drawing ourselves and draw up all the controls as well. We do chose this route for two reasons: +1. It cuts down on your time to read and understand the intricacies of GTK. Instead, you glance through this document and 100 lines of code, you can get started. +2. The standard user controls like text boxes, buttons etc don't work very well with special hardware as input. + +## Data structures +The basic structure used in build the user interface is the struct field: + +```c++ +struct field { + char *cmd; + int x, y, width, height; + char label[30]; + int label_width; + char value[MAX_FIELD_LENGTH]; + char value_type; //NUMBER, SELECTION, TEXT, TOGGLE, BUTTON + int font_index; //refers to font_style table + char selection[1000]; + int min, max, step; +}; +``` + +The field is drawn with coordiantes of x,y,width and height. the text of label[] to the left of the value[] printed to the right. The font used is picked up from a table. The field font_index stores the index that is used to select the font from font_table. + +Four types of fields are possible : NUMBER (like frequency display), SELECTION - one of many (like USB/LSB or bands), TEXT (rarely used, for instance to send CW), TOGGLE (which can be turned on or off - like AGC) or a BUTTON that triggers a command (""Start recording") + +If the field type is SELECTION, the options available are stored in selection field with forward slash between then like "USB/LSB/CW" + +For NUMBER field, the minimum and maximum values are stored in the integers with the step. For instance, the step size for frequency display could be 100 Hz and it can range from 500000 to 21500000. + +Whenever a field is changed by the user, the updated string of value is concantenated with the cmd field to generate a command to be sent to the sdr radio. For instance "r1:freq=" could be the cmd field and if the value is changed to 14070000, then a command string is created as "r1:freq=14070000". The cmd strings are also used as unique identifiers for each field. + +## Drawing the controls +The entire user interface is drawn by our own code using the graphics primitive of drawing lines, rectangles and text. This makes the user interface easy to port to other GUIs or even if we have just a framebuffer to draw on. The controls also use colors from a table. + +All the drawing of fields is done in a single function called draw_field(). It handles the drawing of spectrum and waterfall by calling a different function. + +## Editing the controls +The controls can be moved between each other with up and down arrow keys or touching them or through one of the encoders. The other encoder can be used to change the value. + +## Ticker +Every millisecond, the ui_tick() function is called to perform functions like monitoring any activity on the encoders, switches, Push-To-Talk or the morse key. \ No newline at end of file diff --git a/wsjtx_notes.txt b/doc/wsjtx_notes.md similarity index 82% rename from wsjtx_notes.txt rename to doc/wsjtx_notes.md index 359ef10..67f5662 100644 --- a/wsjtx_notes.txt +++ b/doc/wsjtx_notes.md @@ -1,14 +1,21 @@ -Before installing +# WSJT-X Notes + +## Before installing +``` sudo apt --fix-broken install +``` Download the 32 bit package from the wsjt-x page (the one with armhf in the name), +``` sudo dpkg -i wsjt... +``` you may have to run if it complains about the locales +``` sudo pkg-reconfigure locales - +``` On WSJT-X File > Settings > Radio, Choose "Hamlib NET", the NetServer is set to "127.0.0.1" @@ -17,4 +24,7 @@ File > Settings > Audio, Input Set to "plughw:CARD=Loopback,DEV=1", "Left" File > Settings > Audio, Output Set to "plughw:CARD=Loopback1,DEV=0", "Both" add the line to /etc/rc.local - sudo modprobe snd-aloop enable=1,1,1 index=1,2,3 + +``` +sudo modprobe snd-aloop enable=1,1,1 index=1,2,3 +``` diff --git a/ui_notes.txt b/ui_notes.txt deleted file mode 100644 index 1a2ecc1..0000000 --- a/ui_notes.txt +++ /dev/null @@ -1,36 +0,0 @@ -The sbitx is hackable in various ways. Writing newer and better user interfaces is one way to make it better.This is a short note to explain how it the current gui written in gtk works. - -1. The user interface for a radio is an interesting challenge. It has to work with knobs and buttons as well as a pointer and keyboard. This gtk user interface works with five hardware buttons and two encoders. We use the GTK library to gain access to a screen where we do all the drawing ourselves and draw up all the controls as well. We do chose this route for two reasons: -1.1 It cuts down on your time to read and understand the intricacies of GTK. Instead, you glance through this document and 100 lines of code, you can get started. -1.2 The standard user controls like text boxes, buttons etc don't work very well with special hardware as input. - -2. Data structures -The basic structure used in build the user interface is the struct field: - -struct field { -char *cmd; -int x, y, width, height; -char label[30]; -int label_width; -char value[MAX_FIELD_LENGTH]; -char value_type; //NUMBER, SELECTION, TEXT, TOGGLE, BUTTON -int font_index; //refers to font_style table -char selection[1000]; -int min, max, step; -}; - -2.1 The field is drawn with coordiantes of x,y,width and height. the text of label[] to the left of the value[] printed to the right. The font used is picked up from a table. The field font_index stores the index that is used to select the font from font_table. -2.2 Four types of fields are possible : NUMBER (like frequency display), SELECTION - one of many (like USB/LSB or bands), TEXT (rarely used, for instance to send CW), TOGGLE (which can be turned on or off - like AGC) or a BUTTON that triggers a command (""Start recording") -2.3 If the field type is SELECTION, the options available are stored in selection field with forward slash between then like "USB/LSB/CW" -2.4 For NUMBER field, the minimum and maximum values are stored in the integers with the step. For instance, the step size for frequency display could be 100 Hz and it can range from 500000 to 21500000. -2.5 Whenever a field is changed by the user, the updated string of value is concantenated with the cmd field to generate a command to be sent to the sdr radio. For instance "r1:freq=" could be the cmd field and if the value is changed to 14070000, then a command string is created as "r1:freq=14070000". The cmd strings are also used as unique identifiers for each field. - -3. Drawing the controls -3.1 The entire user interface is drawn by our own code using the graphics primitive of drawing lines, rectangles and text. This makes the user interface easy to port to other GUIs or even if we have just a framebuffer to draw on. The controls also use colors from a table. -3.2 All the drawing of fields is done in a single function called draw_field(). It handles the drawing of spectrum and waterfall by calling a different function. - -4. Editing the controls -4.1 The controls can be moved between each other with up and down arrow keys or touching them or through one of the encoders. The other encoder can be used to change the value. - -5. Ticker -Every millisecond, the ui_tick() function is called to perform functions like monitoring any activity on the encoders, switches, Push-To-Talk or the morse key. \ No newline at end of file