Code: Select all
/*********************************************************************
* Flowcode LED7SEG1 Component Code
*
* File: LED7SEG1_Code.c
*
* (c) 2007 Matrix Multimedia Ltd.
* http://www.matrixmultimedia.com
*
* Software License Agreement
*
* The software supplied herewith by Matrix Multimedia Ltd (the
* β€Companyβ€) for its Flowcode graphical programming language is
* intended and supplied to you, the Company’s customer, for use
* solely and exclusively on the Company's products. The software
* is owned by the Company, and is protected under applicable
* copyright laws. All rights are reserved. Any use in violation
* of the foregoing restrictions may subject the user to criminal
* sanctions under applicable laws, as well as to civil liability
* for the breach of the terms and conditions of this licence.
*
* THIS SOFTWARE IS PROVIDED IN AN β€AS ISβ€ CONDITION. NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
* Changelog:
*
* date | by | description
* -------+----+-----------------------------------------------------
* 120607 | BR | Created
* 160707 | ST | Modified to work with CTL file
* | |
* | |
* | |
*
*
*
********************************************************************/
/*********************************************************************
Return & parameter types:
void
char
short
char*
Pin directions:
0 = OUTPUT
2 = INPUT
3 = BIDIRECTIONAL
%a = SegmentPort
%b = CommonPort
%c = Pattern0
%d = Pattern1
%e = Pattern2
%f = Pattern3
%g = Pattern4
%h = Pattern5
%i = Pattern6
%j = Pattern7
%k = Pattern8
%l = Pattern9
%m = PatternDP
%n = CommonMask
%o = CommonMask_Inv
%p = SegmentMask_Inv
%q = CommonAnode
**********************************************************************
[Settings]
CLSID={C5A410B9-AFEA-4f62-B6D1-78B244980168}
**********************************************************************
[MacroNames]
Count=1
1=ShowDigit
[MacroReturns]
1=void
[MacroIsPrivate]
1=0
[MacroParameters_ShowDigit]
Count=2
1=Value
2=DecimalPoint
[MacroParamTypes_ShowDigit]
1=char
2=char
********************************************************************/
/********************************************************************
* ADDITIONAL CODE
********************************************************************/
/*InitialisationCode_Start*/
/*InitialisationCode_End*/
/*InterruptCode_Start*/
/*InterruptCode_End*/
/********************************************************************
* FUNCTIONS
********************************************************************/
void ShowDigit(char Value, char DecimalPoint)
{
/*Macro_ShowDigit_Start*/
#if (%a == 0)
#define MX_7SEG1_SEGMENT_PORT porta
#define MX_7SEG1_SEGMENT_TRIS trisa
#endif
#if (%a == 1)
#define MX_7SEG1_SEGMENT_PORT portb
#define MX_7SEG1_SEGMENT_TRIS trisb
#endif
#if (%a == 2)
#define MX_7SEG1_SEGMENT_PORT portc
#define MX_7SEG1_SEGMENT_TRIS trisc
#endif
#if (%a == 3)
#define MX_7SEG1_SEGMENT_PORT portd
#define MX_7SEG1_SEGMENT_TRIS trisd
#endif
#if (%a == 4)
#define MX_7SEG1_SEGMENT_PORT porte
#define MX_7SEG1_SEGMENT_TRIS trise
#endif
#if (%b == 0)
#define MX_7SEG1_COMMON_PORT porta
#define MX_7SEG1_COMMON_TRIS trisa
#endif
#if (%b == 1)
#define MX_7SEG1_COMMON_PORT portb
#define MX_7SEG1_COMMON_TRIS trisb
#endif
#if (%b == 2)
#define MX_7SEG1_COMMON_PORT portc
#define MX_7SEG1_COMMON_TRIS trisc
#endif
#if (%b == 3)
#define MX_7SEG1_COMMON_PORT portd
#define MX_7SEG1_COMMON_TRIS trisd
#endif
#if (%b == 4)
#define MX_7SEG1_COMMON_PORT porte
#define MX_7SEG1_COMMON_TRIS trise
#endif
//set pattern array for the display
rom char* cSegmentArray = {%c, %d, %e, %f, %g, %h, %i, %j, %k, %l};
//get pattern for digit
char cSegmentValue = cSegmentArray[Value % 10];
if (DecimalPoint) cSegmentValue &= %m;
//set up ports
MX_7SEG1_COMMON_TRIS = MX_7SEG1_COMMON_TRIS & %o;
MX_7SEG1_SEGMENT_TRIS = MX_7SEG1_SEGMENT_TRIS & %p;
//MX_7SEG1_COMMON_PORT = MX_7SEG1_COMMON_PORT & %o;
//display the digit
#if (%q == 1)
//common anode
MX_7SEG1_SEGMENT_PORT = (MX_7SEG1_SEGMENT_PORT & %p) | cSegmentValue;
MX_7SEG1_COMMON_PORT = (MX_7SEG1_COMMON_PORT | %n);
#else
//common cathode
MX_7SEG1_SEGMENT_PORT = (MX_7SEG1_SEGMENT_PORT | ~%p) & (~cSegmentValue);
MX_7SEG1_COMMON_PORT = (MX_7SEG1_COMMON_PORT & %o);
#endif
//undefine symbols
#undef MX_7SEG1_SEGMENT_PORT
#undef MX_7SEG1_SEGMENT_TRIS
#undef MX_7SEG1_COMMON_PORT
#undef MX_7SEG1_COMMON_TRIS
/*Macro_ShowDigit_End*/
}