Skip to content

Instantly share code, notes, and snippets.

@gzoller
gzoller / E90_KOMBI_control
Created September 19, 2021 18:02
Controlling E90 Instrument Cluster (tachometer) via CAN bus (CANBed module)
#include <mcp_can.h>
#include <SPI.h>
#define lo8(x) (uint8_t)((x) & 0xFF)
#define hi8(x) (uint8_t)(((x)>>8) & 0xFF)
const int SPI_CS_PIN = 17; // CANBed V1
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
uint8_t checkSum = 0xE2;
@gzoller
gzoller / ClassDefModification.scala
Created November 29, 2022 20:16
Scala Compiler Plugin ClassDef Modificaiton
class ReflectionWorker extends StandardPlugin {
val name: String = "reflectionWorker"
override val description: String = "heavy-lift reflection worker"
def init(options: List[String]): List[PluginPhase] =
new ReflectionWorkerPhase :: Nil
}
class ReflectionWorkerPhase extends PluginPhase {
import tpd._
@gzoller
gzoller / MyPhase.scala
Created December 2, 2022 21:33
Attempting to override a method in plugin
class MyPhase extends PluginPhase {
import tpd._
val phaseName = "overrider"
override val runsAfter = Set(Pickler.name)
override def transformTypeDef(tree: TypeDef)(implicit ctx: Context): Tree =
if tree.isClassDef && !tree.rhs.symbol.isStatic then // only look at classes & traits, not objects