From 0b05593a76fa908382518cb429528c213f95875a Mon Sep 17 00:00:00 2001 From: Xavier Date: Sun, 4 Oct 2026 19:29:06 +0200 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"include"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/README | 39 +++++++++++++++ include/display.h | 47 ++++++++++++++++++ include/input.h | 110 ++++++++++++++++++++++++++++++++++++++++++ include/transverter.h | 32 ++++++++++++ include/utils.h | 35 ++++++++++++++ 5 files changed, 263 insertions(+) create mode 100644 include/README create mode 100644 include/display.h create mode 100644 include/input.h create mode 100644 include/transverter.h create mode 100644 include/utils.h diff --git a/include/README b/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/include/display.h b/include/display.h new file mode 100644 index 0000000..d421089 --- /dev/null +++ b/include/display.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019, Vincent Hervieux vincent.hervieux@gmail.com + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author Vincent Hervieux, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef DISPLAY_H +#define DISPLAY_H + +#include +#include +#include +#include + +#define SCREEN_HEIGHT 64 +#define SCREEN_WIDTH 128 + +#define BLACK 0 +#define WHITE 1 + +#ifdef TRANSVERTER +#define OLED_RESET -1 /* -1 = no reset pin */ +#else +#define OLED_RESET 7 /* Use D7 as optional reset pin */ +#endif + +#endif /* DISPLAY_H */ diff --git a/include/input.h b/include/input.h new file mode 100644 index 0000000..8f13a7b --- /dev/null +++ b/include/input.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019, Vincent Hervieux vincent.hervieux@gmail.com + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author Vincent Hervieux, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef INPUT_H +#define INPUT_H + +#include +#define ENC_DECODER (1 << 2) +#include + +class Input +{ + public: + Input(); + /* init inputs, called during setup */ + void init(); + /* read inputs, call within loop, as much as you can */ + void read(); + + /* Enumerations */ + /* modulation selector */ + enum { + MOD_CW = 0x0, + MOD_AM = 0x1, + MOD_FM = 0x2, + MOD_USB = 0x3, + MOD_LSB = 0x4 + }; + + /* Application has the 3 following modes + * - configuration mode to setup offset, default frequencies... + * - transceiver mode to RX/TX on the Cibi band + * - transverter mode to RX on other bands (requires an expansion card) + */ + enum { + CONFIG_MODE = 0x0, + TRANSCEIVER_MODE = 0x1, + TRANSVERTER_MODE = 0x2 + }; + + /* increment can be : + - manual, selecting a digit and changing it by ratating the encoder. + - a step, according to configuration + */ + enum { + INCREMENT_MANUAL = 0x0, + INCREMENT_STEP = 0x1 + }; + + /* getters */ + const int getModulation(); + const int getApplicationMode(); + const int getIncrementMode(); + const int16_t getEncoderIncrement(); + bool buttonClicked(); + bool getTx(); + const int getSMeter(); + const int getClarifier(); + /* setters */ + void setBuiltInLED(uint8_t value) const; + + private: + static void timerIsr(); + /* store the current modulation */ + uint8_t modulation_ : 3; + /* store the current application mode */ + uint8_t application_mode_ : 2; + /* store the current increment mode */ + uint8_t increment_mode_ : 1; + /* store the RX/TX mode */ + uint8_t tx_ : 1; /* 1: transmitting, 0: receiving */ + /* store clarifier input */ + int clarifier_; + /* store SMeter input */ + int smeter_; + /* smeter sample period */ + int smeter_sampling_; + /* button state */ + ClickEncoder::Button button_; + /* encoder increment */ + int16_t increment_; + /* rotary encoder with button */ + static ClickEncoder encoder_; + +}; + +#endif /* INPUT_H */ diff --git a/include/transverter.h b/include/transverter.h new file mode 100644 index 0000000..b3d60a9 --- /dev/null +++ b/include/transverter.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019, Vincent Hervieux vincent.hervieux@gmail.com + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author Vincent Hervieux, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef TRANSVERTER_H +#define TRANSVERTER_H + +#include "vfo.h" + +#endif /* TRANSVERTER_H */ diff --git a/include/utils.h b/include/utils.h new file mode 100644 index 0000000..6e8543a --- /dev/null +++ b/include/utils.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019, Vincent Hervieux vincent.hervieux@gmail.com + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author Vincent Hervieux, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef UTILS_H +#define UTILS_H + +#include + +extern uint32_t quick_pow10(int n); +extern uint32_t add_int32_to_uint32(uint32_t a, int32_t b); + +#endif /* UTILS_H */