Skip to content

Instantly share code, notes, and snippets.

@GOB52
GOB52 / rename_bin.py
Last active February 21, 2022 10:28
Rename firmware.bin to {project name}.bin. (for PlatformIO)
# rename from firmware.bin to projectname.bin
#
# platform.ini
# extra_scripts = pre:rename_bin.py
#
Import("env")
import os
project_name = os.path.basename(os.path.dirname(env["PROJECT_CONFIG"]))
@GOB52
GOB52 / formatString.cpp
Last active February 26, 2023 12:27
formatString
/*
see also https://stackoverflow.com/questions/7315936/which-of-sprintf-snprintf-is-more-secure/35401865#35401865
If you leave memory management to std::string, you don't have to free it yourself.
*/
// Using template
#include <string>
template<typename ...Args> std::string formatString(const char* fmt, Args... args)
{
size_t sz = snprintf(nullptr, 0U, fmt, args...); // calculate length
@GOB52
GOB52 / CheckJsr.java
Last active December 3, 2022 16:36
夏時間移行時にスキップされる存在しない時刻に対してと、サマータイム終了によって2つ存在する時刻に対する mktime の挙動確認
// JSR 310
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class CheckJsr
{
public static void test(String tstr, int y, int m, int d, int hh, int mm, int ss)
{
System.out.println(tstr);
@GOB52
GOB52 / string_and_String.cpp
Created December 8, 2022 10:44
std::string / ARDUINO String の微妙な違い (比較演算)
// std::string / ARDUINO String での 比較
#include <cstdio>
#include <vector>
#include <algorithm>
#ifdef ARDUINO
# include <WString.h>
using string_t = String;
#else
# include <string>
using string_t = std::string;
@GOB52
GOB52 / m5stack_posix_tz_offset.txt
Last active December 11, 2022 10:14
M5Stack setenv();/tzset(); POSIX tz string と 内部で設定される offset の出力結果 ([X] は 逸脱値)
espressif32@4.4.0 / @5.2.0
Location string:POSIX tz string:StandardOffset:DSTOffset:[ ]OK,[X]NG:[ ]OK,[X}NG
<+0330> => 330 * 3600 = 1188000 NG! / 3 * 3600 + 30 * 60 = 12600 OK!
Africa/Abidjan: GMT0: 0: 0 [ ]:[ ]
Africa/Accra: GMT0: 0: 0 [ ]:[ ]
Africa/Addis_Ababa: EAT-3: -10800: 0 [ ]:[ ]
Africa/Algiers: CET-1: -3600: 0 [ ]:[ ]
Africa/Asmara: EAT-3: -10800: 0 [ ]:[ ]
Africa/Bamako: GMT0: 0: 0 [ ]:[ ]
@GOB52
GOB52 / raise_version.py
Created December 26, 2022 14:43
Raise version script for Arduino library
#! /usr/bin/env python3
#
# Raise Version by semantics versioning for Arduino library
#
import os
import sys
import argparse
import re
import json
@GOB52
GOB52 / inherit_LGFX_Sprite.hpp
Created January 1, 2023 09:44
LGFX_Sprite pushPartial
class Sprite : public ::LGFX_Sprite
{
public:
explicit Sprite(::LovyanGFX* parent) : ::LGFX_Sprite(parent) {}
Sprite() : LGFX_Sprite() {}
template<typename T>
void pushPartial(LovyanGFX* dst,
const int32_t dx, const int32_t dy,
const int32_t width, const int32_t height,
@GOB52
GOB52 / inherit_LGFX_Sprite2.hpp
Last active January 2, 2023 06:31
LGFX_Sprite 派生クラス間の Bitblt
class Sprite : public ::LGFX_Sprite
{
public:
explicit Sprite(::LovyanGFX* parent) : ::LGFX_Sprite(parent) {}
Sprite() : LGFX_Sprite() {}
/*!
@brief Bit block transfer of color data corresponding to a pixel rectangle from the specified source sprite to the destination sprite.
@param dst Destination sprite.
@param dx X coodrdinate of the left-top corner of destination rectabgle.
@GOB52
GOB52 / BasicHttpsClient.ino
Created January 11, 2023 13:33
BasicHttpsClient.ino の証明書変更して繋いでみた
/**
BasicHTTPSClient.ino
Created on: 14.10.2018
*/
#include <Arduino.h>
#include <WiFi.h>
@GOB52
GOB52 / M5Unified_HDMI.log
Last active May 15, 2023 09:42
M5Unified + M5ModuleDisplay.h HDMI ログ
// HDMI ケーブル未接続、 DCなしにも関わらず本体液晶にでない時のログ
15:01:41.443 > rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
15:01:41.443 > configsip: 0, SPIWP:0xee
15:01:41.443 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:01:41.443 > mode:DIO, clock div:1
15:01:41.443 > load:0x3fff0030,len:1344
15:01:41.443 > load:0x40078000,len:13924
15:01:41.443 > ho 0 tail 12 room 4
15:01:41.443 > load:0x40080400,len:3600