Merge branch 'master' of git.martlubbers.net:msc-thesis1617
[msc-thesis1617.git] / mtask.class.tex
1 In the \emph{Arduino} ecosystem, shields are available to plug into the
2 microcontroller and add functionality. These shields range from Bluetooth,
3 WiFi, Ethernet, LoRa, LCD screens and much more. Often the functionality
4 available in these shields is housed in a \gls{C++} class. This functionality
5 is ported using little work to \gls{mTask} by just creating a corresponding
6 class with the same functions. As an example, Listing~\ref{lst:lcd} shows parts
7 of the \gls{LCD} class as an \gls{mTask} class functions and as
8 Listing~\ref{lst:lcdc} shown the corresponding \emph{Arduino} class functions.
9
10 \begin{lstlisting}[language=Clean,label={lst:lcd},%
11 caption={Adding the \gls{LCD} to the \gls{mTask} language}]
12 :: LCD = ...
13
14 class lcd v where
15 begin :: (v LCD Expr) (v Int p) (v Int q) -> v () Expr
16 LCD :: Int Int [DigitalPin] ((v LCD Expr) -> Main (v b q)) -> Main (v b q)
17 ...
18 scrollLeft :: (v LCD Expr) -> v () Expr
19 scrollRight :: (v LCD Expr) -> v () Expr
20 ...
21 \end{lstlisting}
22
23 \begin{lstlisting}[language=C++,label={lst:lcdc},%
24 caption={Functions from the \gls{Arduino} \gls{LCD} library}]
25 class LiquidCrystal {
26 public:
27 void begin(uint8_t cols, uint8_t rows);
28 ...
29 void scrollDisplayLeft();
30 void scrollDisplayRight();
31 ...
32 }
33 \end{lstlisting}