'잡동사니'에 해당되는 글 14091건

  1. 2026.02.20 cpp pure virtual function
  2. 2026.02.20 mbed studio / cli
  3. 2026.02.20 antigravity 사용량 끝!
  4. 2026.02.19 sx1276 spi 통신
  5. 2026.02.19 해피빈 기부
  6. 2026.02.18 gcc __cplusplus 선언
  7. 2026.02.18 stm32f103c8t6 cpp std::cout 실패
  8. 2026.02.18 lvgl 속도 제한(?) 해제
  9. 2026.02.18 platform.io + vscode + esp32
  10. 2026.02.18 esp32 on arduino ide
Programming/C++ STL2026. 2. 20. 16:30

sx1276 예제를 보다보니 mbed쪽(?) 드라이버 소스에 함수인데 "= 0"를 해둔게 있어서 이게 머야 하고 검색해보니

순수 가상 함수라는 이상한(?) 이름이 붙은 녀석이 발견되었다.

어떻게 보면 java에서 interface 로 선언되는 녀석과 비슷하게 실 구현체가 없이 선언되고

무조건 구현해서 사용해야 하는 녀석 같은데.. 참 난해한 문법형태구만..

그런데 cpp에 원래 virtual 키워드가 있었던..가?

 

    /*!
     * @brief Checks if the given RF frequency is supported by the hardware
     *
     * @param [IN] frequency RF frequency to be checked
     * @retval isSupported [true: supported, false: unsupported]
     */
    virtual bool CheckRfFrequency( uint32_t frequency ) = 0;

[링크 : https://hwan-shell.tistory.com/223]

[링크 : https://www.geeksforgeeks.org/cpp/pure-virtual-functions-and-abstract-classes/]

 

 

// deriv_VirtualFunctions2.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

class Base {
public:
   virtual void NameOf();   // Virtual function.
   void InvokingClass();   // Nonvirtual function.
};

// Implement the two functions.
void Base::NameOf() {
   cout << "Base::NameOf\n";
}

void Base::InvokingClass() {
   cout << "Invoked by Base\n";
}

class Derived : public Base {
public:
   void NameOf();   // Virtual function.
   void InvokingClass();   // Nonvirtual function.
};

// Implement the two functions.
void Derived::NameOf() {
   cout << "Derived::NameOf\n";
}

void Derived::InvokingClass() {
   cout << "Invoked by Derived\n";
}

int main() {
   // Declare an object of type Derived.
   Derived aDerived;

   // Declare two pointers, one of type Derived * and the other
   //  of type Base *, and initialize them to point to aDerived.
   Derived *pDerived = &aDerived;
   Base    *pBase    = &aDerived;

   // Call the functions.
   pBase->NameOf();           // Call virtual function.
   pBase->InvokingClass();    // Call nonvirtual function.
   pDerived->NameOf();        // Call virtual function.
   pDerived->InvokingClass(); // Call nonvirtual function.
}

 

부모 클래스로 바꾸어서 실행해도 virtual 로 선언된 함수는 무조건 자기 자신의 원래 함수를 호출한다.

내가 누구인지 타입 캐스팅이 되어도 원래꺼를 따라가니 일종의 메타데이터를 가지고 있는걸려나?

Derived::NameOf
Invoked by Base
Derived::NameOf
Invoked by Derived

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/virtual-functions?view=msvc-170]

[링크 : https://mr-dingo.github.io/c/c++뽀개기/2019/01/10/virtual.html]

'Programming > C++ STL' 카테고리의 다른 글

crt0.o libstdc++.a  (0) 2025.08.12
cpp 그래픽 라이브러리  (0) 2025.04.22
cpp 기본 인자 prototype  (0) 2025.03.28
cpp std::to_string(int)  (0) 2025.02.20
cpp string 끝에 한글자 지우기  (0) 2025.02.06
Posted by 구차니
embeded/ARM2026. 2. 20. 15:14

'embeded > ARM' 카테고리의 다른 글

mbed studio with 32f469idiscovery  (0) 2026.02.21
Ethos-U85  (0) 2026.02.06
SVE(Scalable Vector Extension)  (0) 2025.08.28
emmc 파티션 정렬  (0) 2024.02.07
arm asm rev  (0) 2023.09.14
Posted by 구차니

한 30~40분? 두개 동시에 좀 돌렸더니 사용량 끝! 해버렸다

나름 회사에서 google workspace 써서 유료일텐데도 쿼터가 낮은가 보다.

그 와중에 3.1 Pro는 막상 사용하려고 하면 안되면서

3.0 Pro와 동시에 경고 떠서 쭈르륵 못쓰는건 무슨 유머(?) 일까 

 

'개소리 왈왈 > 인공지능' 카테고리의 다른 글

agi를 느꼈다?  (0) 2026.02.24
gemini 동영상 만들기 (유료?)  (0) 2026.02.22
antigravity 설치  (0) 2026.02.11
gemini cli 에서 gemini 3 flash 사용  (0) 2026.02.11
바이브 코딩 ai 코딩의 광풍  (0) 2025.10.13
Posted by 구차니
하드웨어/lora lorawan2026. 2. 19. 15:53

 

CPOL=0 CPHA=0 으로 설정해주고

데이터가 전송되는 동안 NSS를 low로 유지

address 1byte(MSB wnr bit = 1 write, 0 read)

1byte data 로 데이터를 주고 받을수 있는 듯.

 

아쉽게도 통신 확인용 device id 레지스터는 없는 듯 한데..

그나마 그런용도로 쓸만한게 0x42 RegVersion 0x12 로 리턴되나 보면 될 듯

 

+

NRESET 핀을 HIGH로 해주어야 sx1276 이 살아나고

그 외엔 정상적으로 잘 읽는 듯 하다.

void sx1276_read_ver()
{
  uint8_t address = 0x42; // RegVersion
  uint8_t data = 0x00;
  uint16_t len = 1;

  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);
  HAL_Delay(500);

  HAL_GPIO_WritePin(NSS_GPIO_Port, NSS_Pin, GPIO_PIN_RESET);
    HAL_SPI_Transmit(&hspi2, &address, len, 100);
    HAL_SPI_Receive(&hspi2, &data, len, 100);
  HAL_GPIO_WritePin(NSS_GPIO_Port, NSS_Pin, GPIO_PIN_SET);

  printf("sx1276 ver %X\r\n", data);
}

 

ver 0 나와서 당황.. -_-

sx1276 ver 0
sx1276 ver 12

'하드웨어 > lora lorawan' 카테고리의 다른 글

sx1276 raw pakcet  (0) 2026.02.27
lora driver for stm32 written in c  (0) 2026.02.26
LoRa modulation basics  (0) 2025.12.16
lora CR(coding rate)  (0) 2025.12.16
lora evk  (0) 2025.10.02
Posted by 구차니
개소리 왈왈/블로그2026. 2. 19. 10:07

슬슬 또 금액이 차올라서, 이 정도면 되었다 싶어 기부!

근데 내가 이거 리프레시 하면서 눌러 서버가 작동하는 비용을 고려하면

해피빈이 싼건가 고민이 되긴한다.

 

Posted by 구차니
프로그램 사용/gcc2026. 2. 18. 22:22

gcc 로 빌드하면 현재 빌드하는 시스템이 c가 아닌 cpp 라는걸 확인하기 위해(혹은 알려주기 위해)

__cplusplus 라는 선언을 -D__cplusplus 하듯 붙여주는 듯 한데

__cplusplus__가 아니라 왜 앞에만 언더바 두 개 일까.. -_-?

 

__STDC__
In normal operation, this macro expands to the constant 1, to signify that this compiler conforms to ISO Standard C. If GNU CPP is used with a compiler other than GCC, this is not necessarily true; however, the preprocessor always conforms to the standard unless the -traditional-cpp option is used.

This macro is not defined if the -traditional-cpp option is used.

On some hosts, the system compiler uses a different convention, where __STDC__ is normally 0, but is 1 if the user specifies strict conformance to the C Standard. CPP follows the host convention when processing system header files, but when processing user files __STDC__ is always 1. This has been reported to cause problems; for instance, some versions of Solaris provide X Windows headers that expect __STDC__ to be either undefined or 1. See Invocation.

__STDC_VERSION__
This macro expands to the C Standard’s version number, a long integer constant of the form yyyymmL where yyyy and mm are the year and month of the Standard version. This signifies which version of the C Standard the compiler conforms to. Like __STDC__, this is not necessarily accurate for the entire implementation, unless GNU CPP is being used with GCC.

The value 199409L signifies the 1989 C standard as amended in 1994, which is the current default; the value 199901L signifies the 1999 revision of the C standard; the value 201112L signifies the 2011 revision of the C standard; the value 201710L signifies the 2017 revision of the C standard (which is otherwise identical to the 2011 version apart from correction of defects). The value 202311L is used for the -std=c23 and -std=gnu23 modes. An unspecified value larger than 202311L is used for the experimental -std=c2y and -std=gnu2y modes.

This macro is not defined if the -traditional-cpp option is used, nor when compiling C++ or Objective-C.

__STDC_HOSTED__
This macro is defined, with value 1, if the compiler’s target is a hosted environment. A hosted environment has the complete facilities of the standard C library available.

__cplusplus
This macro is defined when the C++ compiler is in use. You can use __cplusplus to test whether a header is compiled by a C compiler or a C++ compiler. This macro is similar to __STDC_VERSION__, in that it expands to a version number. Depending on the language standard selected, the value of the macro is 199711L for the 1998 C++ standard, 201103L for the 2011 C++ standard, 201402L for the 2014 C++ standard, 201703L for the 2017 C++ standard, 202002L for the 2020 C++ standard, 202302L for the 2023 C++ standard, or an unspecified value strictly larger than 202302L for the experimental languages enabled by -std=c++26 and -std=gnu++26.

__OBJC__
This macro is defined, with value 1, when the Objective-C compiler is in use. You can use __OBJC__ to test whether a header is compiled by a C compiler or an Objective-C compiler.

__ASSEMBLER__
This macro is defined with value 1 when preprocessing assembly language.

[링크 : https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html]

 

 Version    __cplusplus
  4.8.3       201300L
  4.9.2       201300L
  5.1.0       201402L

[링크 : https://stackoverflow.com/questions/30995705/cplusplus-201402l-return-true-in-gcc-even-when-i-specified-std-c14[

Posted by 구차니
embeded/Cortex-M3 STM2026. 2. 18. 22:14

아래코드까진 문제가 없는데

class my_class
{
public:
	int i_var;
	int f();
};

int my_class::f()
{
	return ++i_var;
}

int main(void)
{
	my_class *p_my_class = new my_class();
	p_my_class->f();
}

 

iostream을 추가해서 (아직 uart 출력을 연결하진 않고 빌드만 했지만)

std::cout을 통해 출력만 해보려고 했는데

#include <iostream>

class my_class
{
public:
	int i_var;
	int f();
};

int my_class::f()
{
	return ++i_var;
}

int main(void)
{
	my_class *p_my_class = new my_class();
	std::cout << p_my_class->f();
}

 

플래시 용량이 터져나가 버렸다.

cout을 쓰려면 최소 192KB 이상의 flash는 되어야 한다는건가?

22:05:02 **** Incremental Build of configuration Debug for project cpp_test ****
make -j4 all 
arm-none-eabi-g++ "../Core/Src/main.cpp" -mcpu=cortex-m3 -std=gnu++14 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti -fno-use-cxa-atexit -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/main.o"
arm-none-eabi-g++ -o "cpp_test.elf" @"objects.list"   -mcpu=cortex-m3 -T"/home/minimonk/STM32CubeIDE/workspace_1.19.0_cpp/cpp_test/STM32F103C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="cpp_test.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
/home/minimonk/st/stm32cubeide_1.19.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.linux64_1.0.0.202410170706/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld: /home/minimonk/st/stm32cubeide_1.19.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.linux64_1.0.0.202410170706/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-getentropyr.o): in function `_getentropy_r':
(.text._getentropy_r+0xe): warning: _getentropy is not implemented and will always fail
/home/minimonk/st/stm32cubeide_1.19.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.linux64_1.0.0.202410170706/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld: /home/minimonk/st/stm32cubeide_1.19.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.linux64_1.0.0.202410170706/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-getentropyr.o): note: the message above does not take linker garbage collection into account
/home/minimonk/st/stm32cubeide_1.19.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.linux64_1.0.0.202410170706/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld: cpp_test.elf section `.text' will not fit in region `FLASH'
/home/minimonk/st/stm32cubeide_1.19.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.linux64_1.0.0.202410170706/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld: region `FLASH' overflowed by 109220 bytes
collect2: error: ld returned 1 exit status
make: *** [makefile:88: cpp_test.elf] Error 1
"make -j4 all" terminated with exit code 2. Build might be incomplete.

22:05:04 Build Failed. 4 errors, 1 warnings. (took 2s.252ms)

[링크 : https://igotit.tistory.com/entry/STM32CubeIDE-임베디드-코드에서-C-클래스-활용]

 


gpt 말로는 아래를 설정해주라는데, std::cout 하면 버퍼부터 하위시스템 다 끌려온다는거 치고는 너무 큰디..

데드 코드 삭제
-ffunction-sections
-fdata-sections

링커옵션
-Wl,--gc-sections


예외/RTTI 끄기
-fno-exceptions
-fno-rtti

newlib nano
--specs=nano.specs

 

그래서 설정을 보는데, 기본으로 부동소수점 출력/입력은 안하게 되어있고

 

g++ 쪽은 기본적으로 아래의 4개 플래그가 설정되어 있다.

-ffunctions-sections

-fdata-sections

-fno-exceptions

-fno-rtti

 

링커도 -Wl,--gc-sections 되어 있어서 더 옵션으로 먼가 줄일수 있는 상태는 아닌데..

[링크 : https://vuzwa.tistory.com/entry/STM32CubeIDE에서-개발환경-C-or-C로-전환하기]

 

그래서 std::cout 은 포기하고 printf나 쓰라고 하는건가?

그런데 rtti 까지 사용하지 않으면 cpp를 쓰는 이유가 머가 남지 -ㅁ-?

'embeded > Cortex-M3 STM' 카테고리의 다른 글

mbed + stm32cube hal...?  (0) 2026.02.23
Mbed studio on ubuntu 22.04  (0) 2026.02.23
stm32 rtc tamper  (0) 2026.01.29
stm32f103 rtc backup register  (0) 2026.01.29
stm32 hal rcc flag  (0) 2026.01.27
Posted by 구차니
프로그램 사용/lvgl2026. 2. 18. 18:32

기본적으로 30fps 를 출력하는 것 같아서 속도를 더 올릴 수 없나 찾아보는중

 

sdkconfig
#
# HAL Settings
#
CONFIG_LV_DEF_REFR_PERIOD=33
CONFIG_LV_DPI_DEF=130
# end of HAL Settings

 

lv_conf_internal.h
/*====================
   HAL SETTINGS
 *====================*/

/** Default display refresh, input device read and animation step period. */
#ifndef LV_DEF_REFR_PERIOD
    #ifdef CONFIG_LV_DEF_REFR_PERIOD
        #define LV_DEF_REFR_PERIOD CONFIG_LV_DEF_REFR_PERIOD
    #else
        #define LV_DEF_REFR_PERIOD  33      /**< [ms] */
    #endif
#endif

 

lv_demo_benchmark.h
/**
 * Run all benchmark scenes.
 *
 * On the summary end screen the values shall be interpreted according to the following:
 * - CPU usage:
 *    - If `LV_SYSMON_GET_IDLE` is not modified it's measured based on the time spent in
 *      `lv_timer_handler`.
 *    - If an (RT)OS is used `LV_SYSMON_GET_IDLE` can be changed to a custom function
 *      which returns the idle percentage of idle task.
 *
 * - FPS: LVGL attempted to render this many times in a second. It's limited based on `LV_DEF_REFR_PERIOD`
 *
 * - Render time: LVGL spent this much time with rendering only. It's not aware of task yielding,
 *   but simply the time difference between the start and end of the rendering is measured
 *
 * - Flush time: It's the sum of
 *     - the time spent in the `flush_cb` and
 *     - the time spent with waiting for flush ready.
 */
void lv_demo_benchmark(void);
lv_display.c
lv_display_t * lv_display_create(int32_t hor_res, int32_t ver_res)
{
    /*Create a refresh timer*/
    disp->refr_timer = lv_timer_create(lv_display_refr_timer, LV_DEF_REFR_PERIOD, disp);
    LV_ASSERT_MALLOC(disp->refr_timer);
    if(disp->refr_timer == NULL) {
        lv_free(disp);
        return NULL;
    }
}

 

다만 perf test 쪽 헤더를 쓰게 되면 16msec로 60fps로 상향되는 듯.

lv_test_perf_conf.h

/**
 * @file lv_conf.h
 * Configuration file for v9.3.0-dev
 */

/*
 * Copy this file as `lv_conf.h`
 * 1. simply next to `lvgl` folder
 * 2. or to any other place and
 *    - define `LV_CONF_INCLUDE_SIMPLE`;
 *    - add the path as an include path.
 */

/* clang-format off */
#if 1 /* Set this to "1" to enable content */

    #ifndef LV_CONF_H
        #define LV_CONF_H

        #define LV_BUILD_TEST_PERF 1
        #define LV_USE_TEST 1
        /* If you need to include anything here, do it inside the `__ASSEMBLY__` guard */
        #if  0 && defined(__ASSEMBLY__)
            #include "my_include.h"
        #endif

        /*====================
        HAL SETTINGS
        *====================*/

        /** Default display refresh, input device read and animation step period. */
        #define LV_DEF_REFR_PERIOD  16      /**< [ms] */

        /** Default Dots Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
        * (Not so important, you can adjust it to modify default sizes and spaces.) */
        #define LV_DPI_DEF 130              /**< [px/inch] */

'프로그램 사용 > lvgl' 카테고리의 다른 글

squareline studio ebike 예제 screen 전환  (0) 2026.02.20
esp32 lvgl from scratch 는 실패중 ㅠㅠ  (0) 2026.02.18
esp32 lvgl 관련 링크들  (0) 2026.02.18
lvgl 기본 폰트 크기 바꾸기  (0) 2026.02.13
lvgl textarea  (0) 2026.02.11
Posted by 구차니
embeded/esp322026. 2. 18. 18:08

platform.io ide

2026.02.18 기준 6.4M 오호..

 

다운로드 눌러서 가보면 ㅋㅋㅋㅋ

vscode 받고 플러그인 받아서 하란다 ㅋㅋㅋㅋ

아니 먼가 독립 ide인척 하더니 이게 머야 ㅋㅋㅋㅋ

[링크 : https://platformio.org/install/ide?install=vscode]

[링크 : https://platformio.org/platformio-ide]

 

[링크 : https://oesnuj.tistory.com/entry/VS-Code에서-아두이노-개발-PlatformIO로-쉽게-시작하는-방법]

[링크 : https://epictrave.tistory.com/13]

[링크 : https://wikidocs.net/252665]

'embeded > esp32' 카테고리의 다른 글

esp32 on arduino ide  (0) 2026.02.18
esp component 와 idf.py create-project-from-example  (0) 2026.02.10
idf.py help  (0) 2026.02.10
idf 프로젝트 생성하기  (0) 2026.02.08
esp-idf on windows  (0) 2026.02.05
Posted by 구차니
embeded/esp322026. 2. 18. 18:02

오랫만에 설치하려니 헷갈리고 이상하네

일단은 먼가 다운로드 관련 timeout 문제가 있어서 손을 봐야하고

조금 고민하면 당연한거긴 한데.. esp32를 사용하는 아두이노 보드를 손보려는게 아니니

espressif system에서 제공한 보드 매니저를 쓰는게 맞긴하..겠지?

 

아두이노 설치는 스킵

tools - board - boards manager

 

esp32 검색

 

"esp32 by espressif systems" 를 설치(2026.02.18 기준 3.3.7 버전)

 

에러가 발생하면

 

아래 파일을 열어서 아래 내용을 추가. 300초 이상은 접속을 못하게 해놔서 용량 큰 걸 받을수가 없는 듯?

C:\Users\<username>\.arduinoIDE\arduino-cli.yaml 

[링크 : https://github.com/espressif/arduino-esp32/issues/12161#issuecomment-3680101494]

[링크 : https://github.com/espressif/arduino-esp32/issues/12354]

 

 

[링크 : https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html]

[링크 : https://www.bneware.com/blogPost/esp32_arduino_ide]

[링크 : https://fishpoint.tistory.com/9967]

[링크 : https://m.blog.naver.com/mapes_khkim/222901956974]

'embeded > esp32' 카테고리의 다른 글

platform.io + vscode + esp32  (0) 2026.02.18
esp component 와 idf.py create-project-from-example  (0) 2026.02.10
idf.py help  (0) 2026.02.10
idf 프로젝트 생성하기  (0) 2026.02.08
esp-idf on windows  (0) 2026.02.05
Posted by 구차니