User Tools

Site Tools


encoder_tables_in_c

Encoder Tables in C Applications

makefile

Add the “-DDONT_INCLUDE_MIOS_ENC_TABLE” define:

# pass parameters to MIOS wrapper
MIOS_WRAPPER_DEFINES = -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f \
                       -DDONT_INCLUDE_MIOS_ENC_TABLE

main.c

Add your table as such:

/////////////////////////////////////////////////////////////////////////////
// Application specific encoder table
// the default (dummy) table has been disabled via -DDONT_INCLUDE_MIOS_ENC_TABLE
/////////////////////////////////////////////////////////////////////////////
MIOS_ENC_TABLE {
             // sr pin mode
  MIOS_ENC_ENTRY(1, 0, MIOS_ENC_MODE_DETENTED2),
  MIOS_ENC_EOT
};

Reference

Taken from mios wrapper

;; ---[ configuration table for rotary encoders ]---
#ifndef DONT_INCLUDE_MIOS_ENC_TABLE
;; dummy table located in $MIOS_PATH/include/asm
;; If the application should use ENC entries,
;; just add "-DDONT_INCLUDE_MIOS_ENC_TABLE" to MIOS_WRAPPER_DEFINES
;; and build the table within the C program with:
;;
;; MIOS_ENC_TABLE {
;;              // sr pin mode
;;   MIOS_ENC_ENTRY(1, 0, MIOS_ENC_MODE_DETENTED), // VPot #1
;;   MIOS_ENC_ENTRY(1, 2, MIOS_ENC_MODE_DETENTED), // VPot #2
;;   MIOS_ENC_ENTRY(1, 4, MIOS_ENC_MODE_DETENTED), // VPot #3
;;   MIOS_ENC_EOT
;; };
;;
;; The MIOS_MT_* macros are defined in $MIOS_PATH/include/c/cmios.h
#include <mios_enc_table.inc>
#endif

Check out the clockbox app for a real world example.

Enjoy!

encoder_tables_in_c.txt · Last modified: 2008/07/25 14:09 by 127.0.0.1