convert to model
This commit is contained in:
parent
2281778915
commit
017fd46ca5
113
Makefile
113
Makefile
@ -1,113 +0,0 @@
|
||||
#
|
||||
# There exist several targets which are by default empty and which can be
|
||||
# used for execution of your targets. These targets are usually executed
|
||||
# before and after some main targets. They are:
|
||||
#
|
||||
# .build-pre: called before 'build' target
|
||||
# .build-post: called after 'build' target
|
||||
# .clean-pre: called before 'clean' target
|
||||
# .clean-post: called after 'clean' target
|
||||
# .clobber-pre: called before 'clobber' target
|
||||
# .clobber-post: called after 'clobber' target
|
||||
# .all-pre: called before 'all' target
|
||||
# .all-post: called after 'all' target
|
||||
# .help-pre: called before 'help' target
|
||||
# .help-post: called after 'help' target
|
||||
#
|
||||
# Targets beginning with '.' are not intended to be called on their own.
|
||||
#
|
||||
# Main targets can be executed directly, and they are:
|
||||
#
|
||||
# build build a specific configuration
|
||||
# clean remove built files from a configuration
|
||||
# clobber remove all built files
|
||||
# all build all configurations
|
||||
# help print help mesage
|
||||
#
|
||||
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
|
||||
# .help-impl are implemented in nbproject/makefile-impl.mk.
|
||||
#
|
||||
# Available make variables:
|
||||
#
|
||||
# CND_BASEDIR base directory for relative paths
|
||||
# CND_DISTDIR default top distribution directory (build artifacts)
|
||||
# CND_BUILDDIR default top build directory (object files, ...)
|
||||
# CONF name of current configuration
|
||||
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
|
||||
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
|
||||
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
|
||||
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
|
||||
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
|
||||
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
CCADMIN=CCadmin
|
||||
RANLIB=ranlib
|
||||
|
||||
|
||||
# build
|
||||
build: .build-post
|
||||
|
||||
.build-pre:
|
||||
# Add your pre 'build' code here...
|
||||
|
||||
.build-post: .build-impl
|
||||
# Add your post 'build' code here...
|
||||
|
||||
|
||||
# clean
|
||||
clean: .clean-post
|
||||
|
||||
.clean-pre:
|
||||
# Add your pre 'clean' code here...
|
||||
# WARNING: the IDE does not call this target since it takes a long time to
|
||||
# simply run make. Instead, the IDE removes the configuration directories
|
||||
# under build and dist directly without calling make.
|
||||
# This target is left here so people can do a clean when running a clean
|
||||
# outside the IDE.
|
||||
|
||||
.clean-post: .clean-impl
|
||||
# Add your post 'clean' code here...
|
||||
|
||||
|
||||
# clobber
|
||||
clobber: .clobber-post
|
||||
|
||||
.clobber-pre:
|
||||
# Add your pre 'clobber' code here...
|
||||
|
||||
.clobber-post: .clobber-impl
|
||||
# Add your post 'clobber' code here...
|
||||
|
||||
|
||||
# all
|
||||
all: .all-post
|
||||
|
||||
.all-pre:
|
||||
# Add your pre 'all' code here...
|
||||
|
||||
.all-post: .all-impl
|
||||
# Add your post 'all' code here...
|
||||
|
||||
|
||||
# help
|
||||
help: .help-post
|
||||
|
||||
.help-pre:
|
||||
# Add your pre 'help' code here...
|
||||
|
||||
.help-post: .help-impl
|
||||
# Add your post 'help' code here...
|
||||
|
||||
|
||||
|
||||
# include project implementation makefile
|
||||
include nbproject/Makefile-impl.mk
|
||||
|
||||
# include project make variables
|
||||
include nbproject/Makefile-variables.mk
|
@ -1 +1 @@
|
||||
Subproject commit a808b1a1fb577636ebeebcd07374754688d37e71
|
||||
Subproject commit 6ddda2930030db6bd45a81e1547a4ac9a88d90af
|
@ -1,230 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="65">
|
||||
<logicalFolder name="root" displayName="root" projectFiles="true">
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true">
|
||||
<logicalFolder name="app" displayName="app" projectFiles="true">
|
||||
<itemPath>src/app/factory.h</itemPath>
|
||||
<itemPath>src/app/app.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="board" displayName="board" projectFiles="true">
|
||||
<itemPath>src/board/led.h</itemPath>
|
||||
<itemPath>src/board/button.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="mcc_generated_files"
|
||||
displayName="mcc_generated_files"
|
||||
projectFiles="true">
|
||||
<itemPath>src/mcc_generated_files/tmr0.h</itemPath>
|
||||
<itemPath>src/mcc_generated_files/pin_manager.h</itemPath>
|
||||
<itemPath>src/mcc_generated_files/mcc.h</itemPath>
|
||||
<itemPath>src/mcc_generated_files/interrupt_manager.h</itemPath>
|
||||
<itemPath>src/mcc_generated_files/device_config.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="middleware" displayName="middleware" projectFiles="true">
|
||||
<itemPath>src/middleware/blinker.h</itemPath>
|
||||
<itemPath>src/middleware/click_handler.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="xf" displayName="xf" projectFiles="true">
|
||||
<itemPath>src/xf/ireactive.h</itemPath>
|
||||
<itemPath>src/xf/event.h</itemPath>
|
||||
<itemPath>src/xf/xf.h</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="LinkerScript"
|
||||
displayName="Linker Files"
|
||||
projectFiles="true">
|
||||
</logicalFolder>
|
||||
<logicalFolder name="SourceFiles"
|
||||
displayName="Source Files"
|
||||
projectFiles="true">
|
||||
<logicalFolder name="app" displayName="app" projectFiles="true">
|
||||
<itemPath>src/app/factory.c</itemPath>
|
||||
<itemPath>src/app/main.c</itemPath>
|
||||
<itemPath>src/app/app.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="board" displayName="board" projectFiles="true">
|
||||
<itemPath>src/board/led.c</itemPath>
|
||||
<itemPath>src/board/button.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="mcc_generated_files"
|
||||
displayName="mcc_generated_files"
|
||||
projectFiles="true">
|
||||
<itemPath>src/mcc_generated_files/mcc.c</itemPath>
|
||||
<itemPath>src/mcc_generated_files/interrupt_manager.c</itemPath>
|
||||
<itemPath>src/mcc_generated_files/device_config.c</itemPath>
|
||||
<itemPath>src/mcc_generated_files/pin_manager.c</itemPath>
|
||||
<itemPath>src/mcc_generated_files/tmr0.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="middleware" displayName="middleware" projectFiles="true">
|
||||
<itemPath>src/middleware/blinker.c</itemPath>
|
||||
<itemPath>src/middleware/click_handler.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="xf" displayName="xf" projectFiles="true">
|
||||
<itemPath>src/xf/xf.c</itemPath>
|
||||
<itemPath>src/xf/event.c</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
projectFiles="false">
|
||||
<itemPath>Makefile</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<sourceRootList>
|
||||
<Elem>src</Elem>
|
||||
</sourceRootList>
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<confs>
|
||||
<conf name="default" type="2">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<targetDevice>PIC18F87K22</targetDevice>
|
||||
<targetHeader></targetHeader>
|
||||
<targetPluginBoard></targetPluginBoard>
|
||||
<platformTool>PICkit3PlatformTool</platformTool>
|
||||
<languageToolchain>XC8</languageToolchain>
|
||||
<languageToolchainVersion>2.41</languageToolchainVersion>
|
||||
<platform>2</platform>
|
||||
</toolsSet>
|
||||
<packs>
|
||||
<pack name="PIC18F-K_DFP" vendor="Microchip" version="1.7.134"/>
|
||||
</packs>
|
||||
<ScriptingSettings>
|
||||
</ScriptingSettings>
|
||||
<compileType>
|
||||
<linkerTool>
|
||||
<linkerLibItems>
|
||||
</linkerLibItems>
|
||||
</linkerTool>
|
||||
<archiverTool>
|
||||
</archiverTool>
|
||||
<loading>
|
||||
<useAlternateLoadableFile>false</useAlternateLoadableFile>
|
||||
<parseOnProdLoad>false</parseOnProdLoad>
|
||||
<alternateLoadableFile></alternateLoadableFile>
|
||||
</loading>
|
||||
<subordinates>
|
||||
</subordinates>
|
||||
</compileType>
|
||||
<makeCustomizationType>
|
||||
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
|
||||
<makeUseCleanTarget>false</makeUseCleanTarget>
|
||||
<makeCustomizationPreStep></makeCustomizationPreStep>
|
||||
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
|
||||
<makeCustomizationPostStep></makeCustomizationPostStep>
|
||||
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
|
||||
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
|
||||
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
|
||||
</makeCustomizationType>
|
||||
<HI-TECH-COMP>
|
||||
<property key="additional-warnings" value="true"/>
|
||||
<property key="asmlist" value="true"/>
|
||||
<property key="call-prologues" value="false"/>
|
||||
<property key="default-bitfield-type" value="true"/>
|
||||
<property key="default-char-type" value="true"/>
|
||||
<property key="define-macros" value=""/>
|
||||
<property key="disable-optimizations" value="true"/>
|
||||
<property key="extra-include-directories" value=""/>
|
||||
<property key="favor-optimization-for" value="-speed,+space"/>
|
||||
<property key="garbage-collect-data" value="true"/>
|
||||
<property key="garbage-collect-functions" value="true"/>
|
||||
<property key="identifier-length" value="255"/>
|
||||
<property key="local-generation" value="false"/>
|
||||
<property key="operation-mode" value="free"/>
|
||||
<property key="opt-xc8-compiler-strict_ansi" value="false"/>
|
||||
<property key="optimization-assembler" value="true"/>
|
||||
<property key="optimization-assembler-files" value="true"/>
|
||||
<property key="optimization-debug" value="false"/>
|
||||
<property key="optimization-invariant-enable" value="false"/>
|
||||
<property key="optimization-invariant-value" value="16"/>
|
||||
<property key="optimization-level" value="-O0"/>
|
||||
<property key="optimization-speed" value="false"/>
|
||||
<property key="optimization-stable-enable" value="false"/>
|
||||
<property key="preprocess-assembler" value="true"/>
|
||||
<property key="short-enums" value="true"/>
|
||||
<property key="tentative-definitions" value="-fno-common"/>
|
||||
<property key="undefine-macros" value=""/>
|
||||
<property key="use-cci" value="false"/>
|
||||
<property key="use-iar" value="false"/>
|
||||
<property key="verbose" value="false"/>
|
||||
<property key="warning-level" value="-3"/>
|
||||
<property key="what-to-do" value="ignore"/>
|
||||
</HI-TECH-COMP>
|
||||
<HI-TECH-LINK>
|
||||
<property key="additional-options-checksum" value=""/>
|
||||
<property key="additional-options-code-offset" value=""/>
|
||||
<property key="additional-options-command-line" value=""/>
|
||||
<property key="additional-options-errata" value=""/>
|
||||
<property key="additional-options-extend-address" value="false"/>
|
||||
<property key="additional-options-trace-type" value=""/>
|
||||
<property key="additional-options-use-response-files" value="false"/>
|
||||
<property key="backup-reset-condition-flags" value="false"/>
|
||||
<property key="calibrate-oscillator" value="false"/>
|
||||
<property key="calibrate-oscillator-value" value="0x3400"/>
|
||||
<property key="clear-bss" value="true"/>
|
||||
<property key="code-model-external" value="wordwrite"/>
|
||||
<property key="code-model-rom" value=""/>
|
||||
<property key="create-html-files" value="false"/>
|
||||
<property key="data-model-ram" value=""/>
|
||||
<property key="data-model-size-of-double" value="32"/>
|
||||
<property key="data-model-size-of-double-gcc" value="no-short-double"/>
|
||||
<property key="data-model-size-of-float" value="32"/>
|
||||
<property key="data-model-size-of-float-gcc" value="no-short-float"/>
|
||||
<property key="display-class-usage" value="false"/>
|
||||
<property key="display-hex-usage" value="false"/>
|
||||
<property key="display-overall-usage" value="true"/>
|
||||
<property key="display-psect-usage" value="false"/>
|
||||
<property key="extra-lib-directories" value=""/>
|
||||
<property key="fill-flash-options-addr" value=""/>
|
||||
<property key="fill-flash-options-const" value=""/>
|
||||
<property key="fill-flash-options-how" value="0"/>
|
||||
<property key="fill-flash-options-inc-const" value="1"/>
|
||||
<property key="fill-flash-options-increment" value=""/>
|
||||
<property key="fill-flash-options-seq" value=""/>
|
||||
<property key="fill-flash-options-what" value="0"/>
|
||||
<property key="format-hex-file-for-download" value="false"/>
|
||||
<property key="initialize-data" value="true"/>
|
||||
<property key="input-libraries" value="libm"/>
|
||||
<property key="keep-generated-startup.as" value="false"/>
|
||||
<property key="link-in-c-library" value="true"/>
|
||||
<property key="link-in-c-library-gcc" value=""/>
|
||||
<property key="link-in-peripheral-library" value="false"/>
|
||||
<property key="managed-stack" value="false"/>
|
||||
<property key="opt-xc8-linker-file" value="false"/>
|
||||
<property key="opt-xc8-linker-link_startup" value="false"/>
|
||||
<property key="opt-xc8-linker-serial" value=""/>
|
||||
<property key="program-the-device-with-default-config-words" value="true"/>
|
||||
<property key="remove-unused-sections" value="true"/>
|
||||
</HI-TECH-LINK>
|
||||
<PICkit3PlatformTool>
|
||||
<property key="firmware.download.all" value="false"/>
|
||||
</PICkit3PlatformTool>
|
||||
<Tool>
|
||||
<property key="firmware.download.all" value="false"/>
|
||||
</Tool>
|
||||
<XC8-CO>
|
||||
<property key="coverage-enable" value=""/>
|
||||
<property key="stack-guidance" value="false"/>
|
||||
</XC8-CO>
|
||||
<XC8-config-global>
|
||||
<property key="advanced-elf" value="true"/>
|
||||
<property key="constdata-progmem" value="true"/>
|
||||
<property key="gcc-opt-driver-new" value="true"/>
|
||||
<property key="gcc-opt-std" value="-std=c99"/>
|
||||
<property key="gcc-output-file-format" value="dwarf-3"/>
|
||||
<property key="mapped-progmem" value="false"/>
|
||||
<property key="omit-pack-options" value="false"/>
|
||||
<property key="omit-pack-options-new" value="1"/>
|
||||
<property key="output-file-format" value="-mcof,+elf"/>
|
||||
<property key="smart-io-format" value=""/>
|
||||
<property key="stack-size-high" value="auto"/>
|
||||
<property key="stack-size-low" value="auto"/>
|
||||
<property key="stack-size-main" value="auto"/>
|
||||
<property key="stack-type" value="compiled"/>
|
||||
<property key="user-pack-device-support" value=""/>
|
||||
<property key="wpo-lto" value="false"/>
|
||||
</XC8-config-global>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/make-project/1">
|
||||
<name>XFT</name>
|
||||
<creation-uuid>9d10e4b8-91cc-4d86-8f12-a6fd880b26ed</creation-uuid>
|
||||
<make-project-type>0</make-project-type>
|
||||
<sourceEncoding>UTF-8</sourceEncoding>
|
||||
<make-dep-projects/>
|
||||
<sourceRootList>
|
||||
<sourceRootElem>src</sourceRootElem>
|
||||
</sourceRootList>
|
||||
<confList>
|
||||
<confElem>
|
||||
<name>default</name>
|
||||
<type>2</type>
|
||||
</confElem>
|
||||
</confList>
|
||||
<formatting>
|
||||
<project-formatting-style>false</project-formatting-style>
|
||||
</formatting>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
217
src/app/app.c
217
src/app/app.c
@ -1,217 +0,0 @@
|
||||
/**
|
||||
* @author R<EFBFBD>mi Heredero (remi@heredero.ch)
|
||||
* @version 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#include "app.h"
|
||||
#include "factory.h"
|
||||
#include "../middleware/blinker.h"
|
||||
#include "../middleware/click_handler.h"
|
||||
|
||||
void clickL(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickL, 0, 0);
|
||||
}
|
||||
void clickLn(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickLn, 0, 0);
|
||||
}
|
||||
void clickR(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickR, 0, 0);
|
||||
}
|
||||
void clickRn(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickRn, 0, 0);
|
||||
}
|
||||
void endL(APP* me){
|
||||
POST(me, &APP_processEvent, evAPendL, 0, 0);
|
||||
}
|
||||
void endR(APP* me){
|
||||
POST(me, &APP_processEvent, evAPendR, 0, 0);
|
||||
}
|
||||
void longClick(APP* me){
|
||||
POST(me, &APP_processEvent, evAPlongClick, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void APP_init(APP* me){
|
||||
|
||||
me->state = STAP_INIT;
|
||||
|
||||
CLICK_HANDLER_onSingle_click(ch1(), &clickL, me);
|
||||
CLICK_HANDLER_onSingle_click(ch3(), &clickR, me);
|
||||
|
||||
CLICK_HANDLER_onDouble_click(ch1(), &clickLn, me);
|
||||
CLICK_HANDLER_onDouble_click(ch3(), &clickRn, me);
|
||||
|
||||
CLICK_HANDLER_onLong_click(ch1(), &longClick, me);
|
||||
CLICK_HANDLER_onLong_click(ch3(), &longClick, me);
|
||||
|
||||
BLINKER_onFinished(blL(), &endL, me);
|
||||
BLINKER_onFinished(blR(), &endR, me);
|
||||
|
||||
}
|
||||
|
||||
void APP_startBehaviour(APP* me){
|
||||
POST(me, &APP_processEvent, evAPinit, 0, 0);
|
||||
}
|
||||
|
||||
bool APP_processEvent(Event* ev){
|
||||
bool processed = false;
|
||||
APP* me = (APP*) Event_getTarget(ev);
|
||||
APP_STATES oldState = me->state;
|
||||
evIDT evid = Event_getId(ev);
|
||||
|
||||
switch(me->state) { // In state
|
||||
case STAP_INIT:
|
||||
if(evid == evAPinit) {
|
||||
me->state = STAP_WAIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_WAIT:
|
||||
if(evid == evAPclickL) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
BLINKER_emitBlink(blL(), 0);
|
||||
}
|
||||
if(evid == evAPclickLn) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
BLINKER_emitBlinkN(blL(), 0);
|
||||
}
|
||||
if(evid == evAPclickR) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
BLINKER_emitBlink(blR(), 0);
|
||||
}
|
||||
if(evid == evAPclickRn) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
BLINKER_emitBlinkN(blR(), 0);
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_emitBlink(blB(), 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_L:
|
||||
if(evid == evAPclickR){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_emitBlink(blR(), 0);
|
||||
}
|
||||
if(evid == evAPclickRn){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_emitBlinkN(blR(), 0);
|
||||
}
|
||||
if(evid == evAPclickL) {
|
||||
me->state = STAP_WAIT;
|
||||
BLINKER_endBlink(blL());
|
||||
}
|
||||
if(evid == evAPendL) {
|
||||
me->state = STAP_WAIT;
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_endBlink(blL());
|
||||
BLINKER_emitBlink(blB(), 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_R:
|
||||
if(evid == evAPclickL){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_emitBlink(blL(), 0);
|
||||
}
|
||||
if(evid == evAPclickLn){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_emitBlinkN(blL(), 0);
|
||||
}
|
||||
if(evid == evAPclickR) {
|
||||
me->state = STAP_WAIT;
|
||||
BLINKER_endBlink(blR());
|
||||
}
|
||||
if(evid == evAPendR) {
|
||||
me->state = STAP_WAIT;
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_endBlink(blR());
|
||||
BLINKER_emitBlink(blB(), 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_LR:
|
||||
if(evid == evAPclickR) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
BLINKER_endBlink(blR());
|
||||
}
|
||||
if(evid == evAPendR) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
}
|
||||
if(evid == evAPclickL) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
BLINKER_endBlink(blL());
|
||||
}
|
||||
if(evid == evAPendL) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_endBlink(blL());
|
||||
BLINKER_endBlink(blR());
|
||||
BLINKER_emitBlink(blB(), 0);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_W:
|
||||
if(evid == evAPlongClick){
|
||||
me->state = STAP_WAIT;
|
||||
BLINKER_endBlink(blB());
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(oldState != me->state) {
|
||||
switch(oldState) { // on exit
|
||||
case STAP_INIT:
|
||||
break;
|
||||
|
||||
case STAP_WAIT:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_L:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_R:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_LR:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_W:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(me->state) { // on entry
|
||||
case STAP_INIT:
|
||||
break;
|
||||
|
||||
case STAP_WAIT:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_L:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_R:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_LR:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_W:
|
||||
break;
|
||||
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
return processed;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* @author Rémi Heredero (remi@heredero.ch)
|
||||
* @version 1.0.0
|
||||
* @date 2023-06-17
|
||||
*/
|
||||
#ifndef APP_H
|
||||
#define APP_H
|
||||
|
||||
#include "../xf/xf.h"
|
||||
|
||||
typedef enum {
|
||||
STAP_INIT,
|
||||
STAP_WAIT,
|
||||
STAP_BLINKER_L,
|
||||
STAP_BLINKER_R,
|
||||
STAP_BLINKER_LR,
|
||||
STAP_BLINKER_W
|
||||
} APP_STATES;
|
||||
|
||||
typedef enum {
|
||||
evAPinit = 150,
|
||||
evAPclickL,
|
||||
evAPclickLn,
|
||||
evAPclickR,
|
||||
evAPclickRn,
|
||||
evAPendL,
|
||||
evAPendR,
|
||||
evAPlongClick
|
||||
} APP_EVENTS;
|
||||
|
||||
typedef struct {
|
||||
APP_STATES state; // Actual state
|
||||
} APP;
|
||||
|
||||
void APP_init(APP* me);
|
||||
void APP_startBehaviour(APP* me);
|
||||
bool APP_processEvent(Event* ev);
|
||||
|
||||
#endif /* APP_H */
|
||||
|
@ -102,8 +102,7 @@ void Factory_init() {
|
||||
LED_initHW(l8());
|
||||
LED_initHW(l9());
|
||||
LED_initHW(l10());
|
||||
|
||||
|
||||
|
||||
BUTTON_init(b1(), 1);
|
||||
BUTTON_init(b2(), 2);
|
||||
BUTTON_init(b3(), 3);
|
||||
@ -115,42 +114,7 @@ void Factory_init() {
|
||||
CLICK_HANDLER_init(ch1());
|
||||
CLICK_HANDLER_init(ch2());
|
||||
CLICK_HANDLER_init(ch3());
|
||||
|
||||
BLINKER_init(blL());
|
||||
BLINKER_init(blR());
|
||||
BLINKER_init(blB());
|
||||
BLINKER_init(blT());
|
||||
|
||||
APP_init(app());
|
||||
|
||||
theFactory.bar.timeOn = 1000;
|
||||
theFactory.bar.timeOff = 500;
|
||||
theFactory.bar.n = 5;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void warningBlink(void* on_){
|
||||
bool on = (bool)on_;
|
||||
BLINKER_endBlink(blL());
|
||||
BLINKER_endBlink(blR());
|
||||
if(on) {
|
||||
LED_on(l1());
|
||||
LED_on(l10());
|
||||
} else {
|
||||
LED_off(l1());
|
||||
LED_off(l10());
|
||||
}
|
||||
}
|
||||
|
||||
void toggleBlink(void* st_){
|
||||
foo* st = (foo*)st_;
|
||||
uint16_t timeOn= st->timeOn;
|
||||
uint16_t timeOff = st->timeOff;
|
||||
uint8_t n = st->n;
|
||||
BLINKER_setTimeOn(blT(), timeOn);
|
||||
BLINKER_setTimeOff(blT(), timeOff);
|
||||
BLINKER_setNumberOfBlink(blT(), n);
|
||||
}
|
||||
|
||||
//connect objects if required
|
||||
@ -163,19 +127,7 @@ void Factory_build() {
|
||||
BUTTON_onReleased(b1(), &CLICK_HANDLER_emitPbrelease, ch1());
|
||||
BUTTON_onReleased(b2(), &CLICK_HANDLER_emitPbrelease, ch2());
|
||||
BUTTON_onReleased(b3(), &CLICK_HANDLER_emitPbrelease, ch3());
|
||||
|
||||
CLICK_HANDLER_onSingle_click(ch2(), &BLINKER_emitBlinkN, blT());
|
||||
CLICK_HANDLER_onLong_click(ch2(), &toggleBlink, &theFactory.bar);
|
||||
|
||||
BLINKER_onOn(blL(), &LED_on, l1());
|
||||
BLINKER_onOff(blL(), &LED_off, l1());
|
||||
BLINKER_onOn(blR(), &LED_on, l10());
|
||||
BLINKER_onOff(blR(), &LED_off, l10());
|
||||
BLINKER_onOn(blB(), &warningBlink, true);
|
||||
BLINKER_onOff(blB(), &warningBlink, false);
|
||||
|
||||
BLINKER_onOn(blT(), &LED_on, l5());
|
||||
BLINKER_onOff(blT(), &LED_off, l5());
|
||||
|
||||
}
|
||||
|
||||
//start all state machines
|
||||
@ -186,9 +138,4 @@ void Factory_start() {
|
||||
CLICK_HANDLER_startBehaviour(ch1());
|
||||
CLICK_HANDLER_startBehaviour(ch2());
|
||||
CLICK_HANDLER_startBehaviour(ch3());
|
||||
BLINKER_startBehaviour(blL());
|
||||
BLINKER_startBehaviour(blR());
|
||||
BLINKER_startBehaviour(blB());
|
||||
BLINKER_startBehaviour(blT());
|
||||
APP_startBehaviour(app());
|
||||
}
|
@ -14,13 +14,6 @@
|
||||
#include "../board/button.h"
|
||||
#include "../middleware/click_handler.h"
|
||||
#include "../middleware/blinker.h"
|
||||
#include "app.h"
|
||||
|
||||
typedef struct {
|
||||
uint16_t timeOn;
|
||||
uint16_t timeOff;
|
||||
uint8_t n;
|
||||
} foo;
|
||||
|
||||
typedef struct {
|
||||
LED l1_;
|
||||
@ -39,12 +32,6 @@ typedef struct {
|
||||
CLICK_HANDLER ch1_;
|
||||
CLICK_HANDLER ch2_;
|
||||
CLICK_HANDLER ch3_;
|
||||
BLINKER blL_;
|
||||
BLINKER blR_;
|
||||
BLINKER blB_;
|
||||
BLINKER blT_;
|
||||
APP app_;
|
||||
foo bar;
|
||||
} Factory;
|
||||
|
||||
|
||||
@ -72,11 +59,4 @@ CLICK_HANDLER* ch1();
|
||||
CLICK_HANDLER* ch2();
|
||||
CLICK_HANDLER* ch3();
|
||||
|
||||
BLINKER* blL();
|
||||
BLINKER* blR();
|
||||
BLINKER* blB();
|
||||
BLINKER* blT();
|
||||
|
||||
APP* app();
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @author R<EFBFBD>mi Heredero (remi@heredero.ch)
|
||||
* @author Rémi Heredero
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @author Rémi Heredero (remi@heredero.ch)
|
||||
* @author Rémi Heredero
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
Reference in New Issue
Block a user