Skip to content

Instantly share code, notes, and snippets.

@yamamaya
yamamaya / addRGB565.c
Created August 2, 2021 05:17
Add RGB565 colors together with "software packed" method
#include <stdint.h>
uint16_t addRGB565( uint16_t color1, uint16_t color2 ) {
uint16_t c;
c = ( ( color1 & color2 ) + ( ( ( color1 ^ color2 ) & 0xf7de ) >> 1)) & 0x8410;
c = ( ( ( ( ( c + 0xfbdf0 ) ) >> 5 ) & 0xfbff ) + 0x200 ) ^ 0x7bef;
return (color1 + color2 - c) | c;
}
@yamamaya
yamamaya / blendRGB555.c
Created August 2, 2021 05:03
Blend RGB555 colors together with "software packed" method
#include <stdint.h>
uint16_t blendRGB555( uint16_t color1, uint16_t color2 ) {
return( (color1 & color2) + (((color1 ^ color2) & 0x7bde) >> 1) );
}
// testbench
#include <stdio.h>
#define R_bits 5
@yamamaya
yamamaya / debug_macro.c
Last active May 4, 2021 03:58
Macro to turn on/off the debug code
#define DEBUGMODE
#ifdef DEBUGMODE
#define DEBUG(x) _DEBUG(,x)
#define _DEBUG(dummy,x) dummy##x
#else
#define DEBUG(x)
#endif
void func( void ) {
@yamamaya
yamamaya / WT32-SC01-test2.ino
Last active March 27, 2021 02:14
WT32-SC01 with Arduino core and LovyanGFX / large sprite
#include <LovyanGFX.hpp>
struct LGFX_Config {
static constexpr spi_host_device_t spi_host = HSPI_HOST;
static constexpr int dma_channel = 1;
static constexpr int spi_sclk = 14;
static constexpr int spi_mosi = 13;
static constexpr int spi_miso = -1;
static constexpr int spi_dlen = 8;
};
@yamamaya
yamamaya / WT32-SC01-test1.ino
Created March 26, 2021 09:33
WT32-SC01 with LovyanGFX
#include <LovyanGFX.hpp>
struct LGFX_Config {
static constexpr spi_host_device_t spi_host = HSPI_HOST;
static constexpr int dma_channel = 1;
static constexpr int spi_sclk = 14;
static constexpr int spi_mosi = 13;
static constexpr int spi_miso = -1;
static constexpr int spi_dlen = 8;
};
@yamamaya
yamamaya / ISRBlink.ino
Last active September 10, 2020 07:33 — forked from ciniml/ISRBlink.ino
Wio Terminal TC interrupt sample (separated) / TC3 dedicated to 32kHz
@yamamaya
yamamaya / test1.ino
Created May 12, 2020 14:33
Compatibility issues between AtWiFi and TFT_eSPI
//#define NO_WIFI
#ifndef NO_WIFI
#include <AtWiFi.h>
#endif
#include <TFT_eSPI.h>
TFT_eSPI tft;
const char* ssid = "***********";
#include <Adafruit_ZeroDMA.h>
#include <TFT_eSPI.h>
#include "AtWiFi.h"
#include"Free_Fonts.h"
TFT_eSPI tft;
const char* ssid = "******";
const char* password = "*******";
@yamamaya
yamamaya / PowerShell Admin.reg
Created September 9, 2019 10:04
フォルダ右クリック+Shiftに「PowerShell(管理者)ウィンドウをここに開く」を追加する
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\runas]
"Extended"=""
"NoWorkingDirectory"=""
@="PowerShell(管理者)ウィンドウをここに開く(&A)"
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
@yamamaya
yamamaya / MAHMTest.cs
Last active June 2, 2019 08:57
Retrieve hardware information from MSI Afterburner
using System;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.IO.MemoryMappedFiles;
namespace MAHMTest {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();