6 changed files with 129 additions and 94 deletions
@ -1,27 +0,0 @@ |
|||||
HERE:=$(dir $(lastword $(MAKEFILE_LIST))) |
|
||||
-include $(HERE)build.conf |
|
||||
|
|
||||
# Project Name
|
|
||||
TARGET?=blink |
|
||||
|
|
||||
# Configure for debugging
|
|
||||
# common configurations:
|
|
||||
# use DEBUG = 1 and OPT = -Og for debugging
|
|
||||
# or DEBUG = 0 and OPT = -O3 for performance
|
|
||||
DEBUG?=0 |
|
||||
OPT?=-O3 |
|
||||
|
|
||||
# (optional) Includes FatFS source files within project.
|
|
||||
#USE_FATFS = 1
|
|
||||
|
|
||||
# Relative to dir 'src'
|
|
||||
LIBDAISY_DIR?=../../heck_libDaisy |
|
||||
DAISYSP_DIR?=../../heck_DaisySP |
|
||||
|
|
||||
CXXFLAGS+=-Wall -Wno-unused -Wno-reorder-ctor -Wno-switch |
|
||||
|
|
||||
ifneq (,$(findstring g++,$(CXX))) |
|
||||
CXXFLAGS+=-fdiagnostics-color=always |
|
||||
else ifneq (,$(findstring clang,$(CXX))) |
|
||||
CXXFLAGS+=-fcolor-diagnostics |
|
||||
endif |
|
@ -1,19 +1,20 @@ |
|||||
include ../Makefile.conf |
HERE:=$(dir $(lastword $(MAKEFILE_LIST))) |
||||
|
-include $(HERE)../build.conf |
||||
|
|
||||
ALL_SRC=$(wildcard *.cc) |
TARGET ?= main_blink |
||||
TARGET_SRC=main_$(TARGET).cc |
DEBUG ?= 0 |
||||
MODULES_SRC=$(filter-out main_%,$(ALL_SRC)) |
LIBDAISY_DIR ?= ../../heck_libDaisy |
||||
CXX_SRC=$(MODULES_SRC) $(TARGET_SRC) |
DAISYSP_DIR ?= ../../heck_DaisySP |
||||
|
|
||||
$(info CXXFLAGS: $(CXXFLAGS)) |
CXX_STANDARD ?= -std=c++17 |
||||
$(info SOURCES: $(ALL_SRC)) |
CXXFLAGS += -Wall -Wno-unused -Wno-reorder-ctor -Wno-switch |
||||
$(info MODULES: $(MODULES_SRC)) |
CXXFLAGS += -fdiagnostics-color=always |
||||
$(info TARGET_SRC: $(TARGET_SRC)) |
|
||||
$(info CXX_SRC: $(CXX_SRC)) |
|
||||
|
|
||||
# libDaisy Makefile variables
|
ALL_SRC = $(wildcard *.cc) |
||||
CPPFLAGS=$(CXXFLAGS) |
TARGET_SRC = $(TARGET).cc |
||||
SYSTEM_FILES_DIR=$(LIBDAISY_DIR)/core |
MODULES_SRC = $(filter-out main_%,$(ALL_SRC)) |
||||
CPP_SOURCES=$(CXX_SRC) |
CXX_SRC = $(MODULES_SRC) $(TARGET_SRC) |
||||
|
|
||||
include $(SYSTEM_FILES_DIR)/Makefile |
CXX_SOURCES = $(CXX_SRC) |
||||
|
|
||||
|
include $(LIBDAISY_DIR)/core/Makefile |
||||
|
@ -1,16 +1,31 @@ |
|||||
#include "daisy_seed.h" |
#include "daisy_seed.h" |
||||
|
#include "types.hh" |
||||
|
|
||||
namespace ld = daisy; |
namespace Heck { |
||||
|
namespace Constants { |
||||
|
constexpr float BLINK_FREQ_HZ{ 1 }; |
||||
|
} |
||||
|
|
||||
|
ld::DaisySeed hw{}; |
||||
|
|
||||
|
float hz_to_ms(float hz) |
||||
|
{ |
||||
|
return 1000. / hz; |
||||
|
} |
||||
|
|
||||
static ld::DaisySeed hw{}; |
int main() |
||||
|
{ |
||||
|
hw.Init(); |
||||
|
while (true) { |
||||
|
hw.SetLed(true); |
||||
|
hw.DelayMs(hz_to_ms(Constants::BLINK_FREQ_HZ * 2)); |
||||
|
hw.SetLed(false); |
||||
|
hw.DelayMs(hz_to_ms(Constants::BLINK_FREQ_HZ * 2)); |
||||
|
} |
||||
|
} |
||||
|
} // namespace Heck
|
||||
|
|
||||
int main() |
int main() |
||||
{ |
{ |
||||
hw.Init(); |
return Heck::main(); |
||||
while (true) { |
|
||||
hw.SetLed(true); |
|
||||
hw.DelayMs(100); |
|
||||
hw.SetLed(false); |
|
||||
hw.DelayMs(100); |
|
||||
} |
|
||||
} |
} |
||||
|
@ -1,43 +1,54 @@ |
|||||
#include "daisy_seed.h" |
#include "types.hh" |
||||
#include "daisysp.h" |
|
||||
|
|
||||
namespace ld = daisy; |
namespace Heck { |
||||
namespace dsp = daisysp; |
namespace Constants { |
||||
|
} |
||||
static ld::DaisySeed hardware; |
|
||||
static dsp::Oscillator osc; |
|
||||
|
|
||||
void AudioCallback( |
ld::DaisySeed hw{}; |
||||
ld::AudioHandle::InterleavingInputBuffer in, |
dsp::Oscillator osc{}; |
||||
ld::AudioHandle::InterleavingOutputBuffer out, |
|
||||
size_t size) |
void AudioCallback( |
||||
{ |
ld::AudioHandle::InterleavingInputBuffer in, |
||||
float osc_out; |
ld::AudioHandle::InterleavingOutputBuffer out, |
||||
osc.SetFreq(1000); |
size_t size) |
||||
for (size_t i = 0; i < size; i += 2) { |
{ |
||||
osc.SetAmp(1.0); |
float osc_out; |
||||
osc_out = osc.Process(); |
osc.SetFreq(1000); |
||||
osc_out *= 0.01; |
|
||||
out[i] = osc_out; |
for (size_t i = 0; i < size; i += 2) { |
||||
out[i + 1] = osc_out; |
osc.SetAmp(1.0); |
||||
|
osc_out = osc.Process(); |
||||
|
osc_out *= 0.005; |
||||
|
out[i] = osc_out; |
||||
|
out[i + 1] = osc_out; |
||||
|
} |
||||
} |
} |
||||
} |
|
||||
|
|
||||
|
void init() |
||||
|
{ |
||||
|
hw.Configure(); |
||||
|
hw.Init(); |
||||
|
hw.SetAudioBlockSize(4); |
||||
|
float samplerate = hw.AudioSampleRate(); |
||||
|
|
||||
int main(void) |
osc.Init(samplerate); |
||||
{ |
osc.SetWaveform(osc.WAVE_SIN); |
||||
hardware.Configure(); |
osc.SetAmp(1.f); |
||||
hardware.Init(); |
osc.SetFreq(1000); |
||||
hardware.SetAudioBlockSize(4); |
|
||||
|
|
||||
float samplerate = hardware.AudioSampleRate(); |
hw.StartAudio(AudioCallback); |
||||
|
} |
||||
|
|
||||
osc.Init(samplerate); |
void mainloop() |
||||
osc.SetWaveform(osc.WAVE_SIN); |
{ |
||||
osc.SetAmp(1.f); |
for (;;) {} |
||||
osc.SetFreq(1000); |
} |
||||
|
} // namespace Heck
|
||||
|
|
||||
hardware.StartAudio(AudioCallback); |
|
||||
|
|
||||
while (true) {} |
int main(void) |
||||
|
{ |
||||
|
Heck::init(); |
||||
|
Heck::mainloop(); |
||||
|
return 0; |
||||
} |
} |
||||
|
@ -0,0 +1,34 @@ |
|||||
|
#ifndef HECK_DAISY_TYPES_HH |
||||
|
#define HECK_DAISY_TYPES_HH |
||||
|
|
||||
|
#include <cstdint> |
||||
|
#include "daisy_seed.h" |
||||
|
#include "daisysp.h" |
||||
|
|
||||
|
namespace Heck { |
||||
|
|
||||
|
// fundamental types
|
||||
|
using u8 = uint8_t; |
||||
|
using u16 = uint16_t; |
||||
|
using u32 = uint32_t; |
||||
|
using u64 = uint64_t; |
||||
|
|
||||
|
using i8 = int8_t; |
||||
|
using i16 = int16_t; |
||||
|
using i32 = int32_t; |
||||
|
using i64 = int64_t; |
||||
|
|
||||
|
using f32 = float; |
||||
|
using f64 = double; |
||||
|
|
||||
|
// namespace aliases
|
||||
|
namespace ld = daisy; |
||||
|
namespace dsp = daisysp; |
||||
|
|
||||
|
// type aliases from libs
|
||||
|
using Samplerate = ld::SaiHandle::Config::SampleRate; |
||||
|
|
||||
|
} // namespace Heck
|
||||
|
|
||||
|
|
||||
|
#endif |
Loading…
Reference in new issue