ce program est un test non fini

Dependencies:   mbed BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
guillaume_m
Date:
Wed Nov 18 08:07:27 2020 +0000
Parent:
1:a7abb5c6f912
Commit message:
azertyuiop

Changed in this revision

F746_GUI.lib Show diff for this revision Revisions of this file
F746_GUI_Other.lib Show diff for this revision Revisions of this file
F746_OL_GUI.lib Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show diff for this revision Revisions of this file
MATH_LIB_1.lib Show diff for this revision Revisions of this file
TS_DISCO_F746NG.lib Show diff for this revision Revisions of this file
func_ol.cpp Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main1.cpp Show diff for this revision Revisions of this file
main1.hpp Show diff for this revision Revisions of this file
prog_util/fonctions.cpp Show annotated file Show diff for this revision Revisions of this file
prog_util/header.h Show annotated file Show diff for this revision Revisions of this file
--- a/F746_GUI.lib	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/MikamiUitOpen/code/F746_GUI/#687ec6183385
--- a/F746_GUI_Other.lib	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/InoueTakashi/code/F746_GUI_Other/#c77f45e79881
--- a/F746_OL_GUI.lib	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/InoueTakashi/code/F746_OL_GUI/#d7dc710446a8
--- a/LCD_DISCO_F746NG.lib	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- a/MATH_LIB_1.lib	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/InoueTakashi/code/MATH_LIB_1/#d75b71489993
--- a/TS_DISCO_F746NG.lib	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- a/func_ol.cpp	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-#include "mbed.h"
-
-#include "BlinkLabel.hpp"
-#include "ButtonGroup.hpp"
-#include "SeekbarGroup.hpp"
-#include "Label.hpp"
-
-#include "GUIconst.hpp"     //GUI用定数  (TI)
-#include "GUIinit.hpp"     //GUI初期化 (TI)
-#include "ButtonGroupOL.hpp"     //ButtonGroupオーバーラップクラス (TI)
-#include "NumericLabelOL.hpp"   //Numerical Labelオーバーラップクラス (TI)
-#include "Circle.hpp"     //GUI 円クラス (TI)
-#include "Rand.hpp"   //乱数発生クラス (TI)
-
-using namespace Mikami;     //Mikami 名前空間を使用
-using namespace TakaIno;    //TakaIno 名前空間を使用 (TI)
-
-Ticker timer;                 //タイマ割り込み
-
-GUIinit     guiobj;      //GUIクラスオブジェクト生成
-Circle cirary[ GUI_CIRCLE_MAX ]={DEF_CIR_INFO[0], DEF_CIR_INFO[1],DEF_CIR_INFO[2], DEF_CIR_INFO[3],
-                        DEF_CIR_INFO[4], DEF_CIR_INFO[5],DEF_CIR_INFO[6]};
-ButtonGroupOL btnary;    //ButtonGroupOLクラスオブジェクトの生成     
-Rand    rndobj;         //乱数発生クラスオブジェクト生成
-//ゲーム時間表示
-Label lb_time_obj(425,205, "Time", Label::LEFT, Font16, LCD_COLOR_YELLOW, LCD_COLOR_BLUE);   //
-NumericLabelOL<int> timeobj(425, 220, "%03d", G_GAME_LIMIT_TIME, Label::LEFT, Font16, LCD_COLOR_WHITE, LCD_COLOR_DARKBLUE);
-//ゲーム得点表示
-Label lb_score_obj(425,235, "Score", Label::LEFT, Font16, LCD_COLOR_CYAN, LCD_COLOR_BLUE);   //
-NumericLabelOL<int> scoreobj(425, 250, "%04d", 0, Label::LEFT, Font16, LCD_COLOR_RED, LCD_COLOR_WHITE);
-              
-uint16_t btn_width = GUI_BTN_WIDTH;     //ボタン表示の幅
-int     g_btn_num = 4;      ////ボタンの個数
-int     g_bln_num = GUI_CIRCLE_MAX;
-int     rndary[2], befo_rndary[2] = {-1,-1};      //今回と前回の乱数値用配列
-
-int g_game_time = 0;        //ゲーム時間用変数
-int g_game_prcs = 0;        //ゲーム中のプロセス変数、最初は待機プロセス
-
-//タイマ割り込みハンドラ
-void TimerIsr()
-{
-    if( g_game_prcs == 1 )    {     //「ゲーム中プロセス」時に処理する
-        g_game_time++;      //ゲーム時間をカウントアップ
-        if( g_game_time > G_GAME_LIMIT_TIME ) {
-            //ゲーム終了時間になったら「ゲーム終了プロセス」にする
-            g_game_time = G_GAME_LIMIT_TIME;
-            g_game_prcs = 2;
-        }
-    }
-}   
-//グラフィック初期化   
-void gui_init(void)
-{
-  //GUIオブジェクトで、フォント16とボタン幅をセット
-    guiobj.SetInit(Font16, btn_width);
-}
-
-// メインタイトルの表示
-//void dsp_main_title(string main_title)
-void dsp_main_title(char main_title[])
-{
-    string str = main_title;
-    // メインタイトルの表示、中央位置、フォント16
-    Label title_obj(0,0, main_title, Label::CENTER, Font16);   //   
-}
-
-//バルーン表示
-void dsp_baloon(void)
-{
- //円オブジェクトにより、円を描画する
-    for( int idx = 0; idx < g_bln_num; idx++ ) {
-        cirary[idx].DrawCircle(true);
-    }    
-}
-
-//idx番のバルーンに触ったかどうかチェックする
-bool chk_baloon_tch(int idx)
-{
-    return cirary[idx].CircleTouched();
-}
-
-//idx番のバルーンの色を反転する
-void rvs_baloon_col(int idx)
-{
-      //idx番目の円を触ったら、円の色を反転する
-      cirary[idx].ReverseCircleColor();
-}
-
-//idx番のバルーンの表示位置を動かす
-void chg_baloon_pos(int idx)
-{
-       cirary[idx].ChangeCirclePos();
-}
-
-//idx番のバルーンの表示位置を動かすことを許可する
-void ena_baloon_mov(int idx, bool mov_flg)
-{
-       cirary[idx].MoveCircle(mov_flg);
- }
-
-
-//ボタン初期化
-void btn_init()
-{
-     //ボタン1(end),2,3を無効に  ボタン0(start)を有効のままにする
-    btnary.Inactivate(1);    btnary.Inactivate(2);    btnary.Inactivate(3);
-  
- }
- 
- //ボタンの有効無効をセットする
- void set_btn_act_inact(bool act_ary[])
- {
-     for( int i = 0; i < g_btn_num; i++)
-     {
-        if( act_ary[i] )   {
-           btnary.Activate(i); 
-        }
-        else   {
-           btnary.Inactivate(i);
-        }   
-     } 
- }
- 
-//あるボタン番号のボタンタッチを調べる
-bool chk_btn_tch(int btn_num)
-{
-    return btnary.Touched(btn_num);     
-}
-
-//新しい乱数値をセットする
-void set_new_rand(void)
-{
-   //乱数用配列に、1回前と異なった乱数値を入れる
-    for( int idx=0; idx < 2; idx++) {
-        do {
-           rndary[idx] = (int)rndobj.GetRand(g_bln_num);
-        } while( rndary[idx]==befo_rndary[idx]);
-        befo_rndary[idx] = rndary[idx];
-    }    
-}
-
-
-//idx番目のバルーンが、2つの乱数と一致していれば加点、違っていれば減点する                 
-void chk_baloon_rand(int idx, int *score)
-{
-        if( idx == rndary[0] )  *score += GUI_ADD_POINT1;//乱数0と一致している円であれば、加点
-        else if (idx == rndary[1] ) *score += GUI_ADD_POINT2;//乱数1と一致している円であれば、加点
-        else    *score += GUI_DEME_POINT;    //それ以外の円であれば、減点    
-}
-
-//ゲーム時間表示の初期化
-void init_game_time(void)
-{
-    g_game_time = 0;
-}
-
- //ゲーム中プロセスであれば、残り時間の表示
-void dsp_game_time(void)
-{
-    timeobj.Draw("%03d", G_GAME_LIMIT_TIME - g_game_time,LCD_COLOR_WHITE, LCD_COLOR_DARKBLUE);
- }          
-
-//ゲーム得点の初期化
-void init_game_score(void)
-{
-    ;
-}
-
- //ゲーム得点の表示
-void dsp_game_score(int score)
-{
-    if( score >= 0 )    {
-        scoreobj.Draw("%04d", score, LCD_COLOR_BLACK, LCD_COLOR_GREEN);
-    } else    {
-        scoreobj.Draw("%04d", score, LCD_COLOR_WHITE, LCD_COLOR_RED);
-    }   
-}
-
-//0.1秒毎のタイマ割り込みを有効にする
-void ena_tim_irt(double tim_intvl)
-{
-    timer.attach(&TimerIsr, tim_intvl);      //0.1秒ごとのタイマ割り込みを有効にする     
-    
-}         
-    
-    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 18 08:07:27 2020 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
+
+
+#include "header.h"
+
+int main(){
+  uint8_t status;   
+  
+  BSP_LCD_Init();
+  BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
+  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
+  status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
+    if (status != TS_OK) {
+        BSP_LCD_Clear(LCD_COLOR_RED);
+        BSP_LCD_SetBackColor(LCD_COLOR_RED);
+        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+        BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
+    } 
+    else {
+        BSP_LCD_Clear(LCD_COLOR_BLACK);
+        BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
+        int rejouer=0;
+        GRILLE G={0};
+        GRILLE Gsomme={0};
+        init_cellules(G);
+        partie(G,Gsomme);
+        rejouer = fin_de_partie(G,Gsomme);
+        if (rejouer==1){
+            main();
+            }
+    }
+  return 0;    
+}
+
+
--- a/main1.cpp	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-//--------------------------------------------------------------------------------
-//  バルーンタッチゲーム・プログラム
-//
-//
-//  date:   2016/04/27
-//  rev 0.9   date: 2016/5/18
-//  rev 1.0   2016/6/8
-//  rev 1.1     2016/7/2
-//  author: Copyright (c) 2016 Takashi Inoue
-//--------------------------------------------------------------------------------
-#include "main1.hpp"       //
-
-extern GUIinit  guiobj;
-extern  Circle cirary[GUI_CIRCLE_MAX];
-extern  ButtonGroupOL btnary;
-extern  NumericLabelOL<int> timeobj;
-
-extern int  g_bln_num;  //バルーン表示個数
-extern  int g_game_time;        //ゲーム時間用変数
-extern  int g_game_prcs;        //ゲーム中のプロセス変数、最初は待機プロセス
-
-extern void gui_init(void);
-//extern  void dsp_main_title(string main_title); // メインタイトルの表示
-extern  void dsp_main_title(char main_title[]); // メインタイトルの表示
-extern  void dsp_baloon(void);  //バルーン表示
-
-extern  void btn_init(void);    //ボタン初期化
-extern  bool chk_btn_tch(int btn_num);  //あるボタン番号のボタンタッチを調べる
-extern  void set_btn_act_inact(bool act_ary[]); //ボタンの有効無効をセットする
-
-extern  void set_new_rand(void);    //新しい乱数値をセットする
-extern  void chk_baloon_rand(int idx, int *score);//idx番目のバルーンが、2つの乱数と一致していれば加点、違っていれば減点する     
-extern  bool chk_baloon_tch(int idx);   //idx番のバルーンに触ったかどうかチェックする
-extern  void rvs_baloon_col(int idx);   //idx番のバルーンの色を反転する
-extern  void chg_baloon_pos(int idx);    //idx番のバルーンの表示位置を動かす   
-extern  void ena_baloon_mov(int idx, bool mov_flg); //idx番のバルーンの表示位置を動かすことを許可する
-                
-extern  void init_game_time(void);  //ゲーム時間表示の初期化
-extern  void dsp_game_time(void);   //ゲーム中プロセスであれば、残り時間の表示
-
-extern  void init_game_score(void); //ゲーム得点の初期化
-extern  void dsp_game_score(int score); //ゲーム得点の表示
-
-extern void TimerIsr();     //タイマ割り込みハンドラ
-//0.1秒毎のタイマ割り込みを有効にする
-extern  void ena_tim_irt(double tim_intvl);
-
-//----- メイン関数 -----------------------------
-int main()
-{
-    int btn_num = 0;        //今回押されたボタンの番号
-    int befo_btn_num = -1;  //前回押されたボタンの番号
-/*課題6 */    bool btn_act_ary[4] = {true, false, false, false};     //ボタンの有効フラグを入れる配列
-    int score = 0;     //ゲーム点数     
-    int idx;            //各種配列操作用添え字
-
-     gui_init(); //グラフィック初期化
-     
-     g_bln_num = 7;    //バルーン表示個数設定
-     
-    //ボタン初期化     
-    set_btn_act_inact(btn_act_ary); //ボタンの有効無効をセットする         
-         
- /*課題5 */   // メインタイトルの表示
-    dsp_main_title("+++ Baloon Touch! GAME +++");   // メインタイトルの表示
- 
- /**/ //ゲーム時間の表示
-     init_game_time();  //ゲーム時間表示の初期化
- 
-    //ゲーム得点の表示
-     init_game_score();   //ゲーム得点表示の初期化    
-
- /**/
-    dsp_baloon();  //バルーン表示 
- 
-     ena_tim_irt(0.1f); //0.1秒毎のタイマ割り込みを有効にする
-    
- /*課題4*/  //無限ループ
-    while(1) {
-        //ボタン番号btn_numのボタンタッチを調べる
-        if( chk_btn_tch(btn_num) == true )  {            
-            //ボタンが押され、1回目に押されたボタンと異なっていたら処理を行う
-            if( befo_btn_num != btn_num )   {
-                //今回押されたボタン番号を、1回前に押されたボタン番号として保存する
-                 befo_btn_num = btn_num;
-                
- /*課題2*/         switch(btn_num) {       //ボタン番号により処理を分ける
-                    case 0:     //[start]ボタンが押された
-                        btn_act_ary[0] = false;   //ボタン0(start)を無効にする
-                        btn_act_ary[1] = true;     //ボタン1(end)を有効にする
-                        set_btn_act_inact(btn_act_ary); //ボタンの有効無効をセットする                       
-
- /*課題3*/                 //すべての円の移動を開始する
-                        for( idx=0; idx < g_bln_num; idx++) {
-                             //idx番のバルーンの表示位置を動かすことを許可する
-                            ena_baloon_mov(idx, true);
-                        }
-                        score = 0;      //得点を0クリア
- 
-                        set_new_rand();    //新しい2つの乱数値をセットする
-                        
-                        g_game_time = 0;    //ゲーム時間を0クリア
-                        g_game_prcs = 1;    //ゲーム中プロセスにする
-                        
-                        break;
-                    case 1:     //[end]ボタンが押された
-                        g_game_prcs = 2;    //ゲーム終了プロセスにする
-                        
-                        btn_act_ary[1] = false;   //ボタン1(end)を無効にする
-                        btn_act_ary[0] = true;     //ボタン0(start)を有効にする
-                        set_btn_act_inact(btn_act_ary); //ボタンの有効無効をセットする       
-                                               
-                         befo_btn_num = -1;  //1回前に押されたボタンは無しとする
-
-                        //すべてのバルーンの移動を停止する
-                        for( idx=0; idx < g_bln_num; idx++) {
-                            //idx番のバルーンの表示位置を動かすことを禁止する
-                            ena_baloon_mov(idx, false);
-                        }
-
-                        g_game_prcs = 0;    //待機プロセスにする
-
-                        break;
-                     default:
-                        break;
-                }
-            }
-        }
-/* 課題7*/
-        btn_num++;  //ボタン番号を増加
-        if( btn_num >= GUI_NUMBER_BUTTONS ) btn_num=0;  //ボタン番号範囲内に限定する
-
-        if( g_game_prcs == 1 )    {         //ゲーム中プロセスであれば以下の処理を行う
-
-             for( idx=0; idx < g_bln_num; idx++) {
-                //idx番のバルーンの表示位置を動かす
-                chg_baloon_pos(idx);       
-                                 
-                //idx番のバルーンに触ったかどうかチェックする
-                if( chk_baloon_tch(idx) )   {
-                  
-                    rvs_baloon_col(idx);    //idx番のバルーンの色を反転する
-
-                    chk_baloon_rand(idx, &score);  //idx番目のバルーンが、2つの乱数と一致していれば加点、違っていれば減点する                 
-                 }
-            }
-            
-           //ゲーム中プロセスであれば、残り時間の表示
-             dsp_game_time();
-
-            //ゲーム中プロセスであれば、得点の表示
-             dsp_game_score(score);           
-          
-        }
-
-        //以下は、タイマにより、ゲームが終了する場合の処理
-        if( g_game_prcs == 2 ) {
-            btn_act_ary[1] = false;   //ボタン1(end)を無効にする
-            btn_act_ary[0] = true;     //ボタン0(start)を有効にする
-            set_btn_act_inact(btn_act_ary); //ボタンの有効無効をセットする       
-                        
-            befo_btn_num = -1;  //1回前に押されたボタンは無しとする
-
-            //すべての円の移動を停止する
-            for( idx=0; idx < g_bln_num; idx++) {
-                 //idx番のバルーンの表示位置を動かすことを禁止する
-               ena_baloon_mov(idx, false);
-            }
-            g_game_prcs = 0;    //待機プロセスにする
-        }
-
-        wait(0.01f);      //10ms待つ
-
-    }
-}
-
-
-
-
-
-
-
-
-
--- a/main1.hpp	Sat Jul 02 05:39:15 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-
-#include "mbed.h"
-
-#include "BlinkLabel.hpp"
-#include "ButtonGroup.hpp"
-#include "SeekbarGroup.hpp"
-
-#include "GUIconst.hpp"     //GUI用定数  (TI)
-#include "GUIinit.hpp"     //GUI初期化 (TI)
-#include "ButtonGroupOL.hpp"     //ButtonGroupオーバーラップクラス (TI)
-#include "NumericLabelOL.hpp"   //Numerical Labelオーバーラップクラス (TI)
-#include "Circle.hpp"     //GUI 円クラス (TI)
-#include "Rand.hpp"   //乱数発生クラス (TI)
-
-using namespace Mikami;     //Mikami 名前空間を使用
-using namespace TakaIno;    //TakaIno 名前空間を使用 (TI)
-
-DigitalOut led(LED1);
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/prog_util/fonctions.cpp	Wed Nov 18 08:07:27 2020 +0000
@@ -0,0 +1,327 @@
+#include "header.h"
+
+TS_StateTypeDef TS_State;
+
+void init_cellules(GRILLE G){
+	int demarrer=0;
+	int x;
+	int y;
+	int l;
+	int h;
+	while(demarrer==0){
+		Affichagepxl2_debut(G);
+		if(TS_State.touchDetected!=0){
+			if (TS_State.touchX[0]>Gauche_bouton_demarrer && TS_State.touchY[0]<Bas_bouton_demarrer){
+				demarrer=1;
+			}
+			else{
+				x = TS_State.touchX[0],
+				y = TS_State.touchY[0];
+				l = (x-1)%2 ;
+				h = (y-1)%2 ;
+				G[l][h]=1;
+				Affichagepxl2_debut(G);
+			}
+		}
+		G[10][10]=1;
+		G[10][12]=1;
+		G[13][10]=1;
+		G[14][11]=1;
+		G[14][12]=1;
+		G[14][13]=1;
+		G[11][13]=1;
+		G[12][13]=1;
+		G[13][13]=1;
+		demarrer=1;
+	}
+}
+
+
+
+
+
+void Changementetat(GRILLE G, GRILLE Gsomme) //réactualise les états des cases dans G en fonction des cases adjacentes dans Gsomme
+{
+	int l;
+	int h;
+	for (l=1; l<LONGUEUR; l++)
+	{
+		for (h=1; h<HAUTEUR; h++)
+		{	
+			if (G[l][h]==1)
+			{
+				if (Gsomme[l][h]<=CVA_VIVANT && Gsomme[l][h]>=CVA_MORT) //condition pour la survie d'une case
+				{
+					G[l][h]=1;
+				}
+				else //meurt d'isolement ou d'étouffement
+				{
+					G[l][h]=0;
+				}
+			}
+			else if (G[l][h]==0)
+			{
+				if (Gsomme[l][h]==CVA_VIVANT) //passage a l'état vivant si la case est morte
+				{
+					G[l][h]=1;
+				}
+				else 
+				{
+					G[l][h]=0;
+				}
+			}
+		}
+	}
+}
+
+void Affichagepxl2(GRILLE G) //surtout ne pas confondre les dimensions de l'écran avec les dimension du tableau des cases si on utilise des pixels 2x2 ou plus
+{
+	int l; //longueur sur G
+	int h; //hauteur sur H
+	for (l=1; l<LONGUEUR; l+=2)
+	{
+		for (h=1; h<HAUTEUR; h+=2)
+		{	
+			int x=(2*l)+1;  //position sur l'écran x,y
+			int y=(2*h)+1;
+			if (G[l][h]==1){
+				BSP_LCD_DrawPixel(x,y,couleurvivante);
+				BSP_LCD_DrawPixel(x+1,y,couleurvivante);
+				BSP_LCD_DrawPixel(x,y+1,couleurvivante);
+				BSP_LCD_DrawPixel(x+1,y+1,couleurvivante);
+			}
+			else if (G[l][h]==0){
+				BSP_LCD_DrawPixel(x,y,couleurmorte);
+				BSP_LCD_DrawPixel(x+1,y,couleurmorte);
+				BSP_LCD_DrawPixel(x,y+1,couleurmorte);
+				BSP_LCD_DrawPixel(x+1,y+1,couleurmorte);
+			}
+		}
+	}
+	BSP_LCD_SetTextColor(couleur_stop);
+	BSP_LCD_FillRect(400,0,79,60);
+	BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+	BSP_LCD_DisplayStringAt(0,0, (uint8_t *)"STOP", RIGHT_MODE);
+}
+
+void Affichagepxl2_debut(GRILLE G) 
+{
+	int l; //longueur sur G
+	int h; //hauteur sur H
+	for (l=1; l<LONGUEUR; l+=2)
+	{
+		for (h=1; h<HAUTEUR; h+=2)
+		{	
+			int x=(2*l)+1;  //position sur l'écran x,y
+			int y=(2*h)+1;
+			if (G[l][h]==1){
+				BSP_LCD_DrawPixel(x,y,couleurvivante);
+				BSP_LCD_DrawPixel(x+1,y,couleurvivante);
+				BSP_LCD_DrawPixel(x,y+1,couleurvivante);
+				BSP_LCD_DrawPixel(x+1,y+1,couleurvivante);
+			}
+			else if (G[l][h]==0){
+				BSP_LCD_DrawPixel(x,y,couleurmorte);
+				BSP_LCD_DrawPixel(x+1,y,couleurmorte);
+				BSP_LCD_DrawPixel(x,y+1,couleurmorte);
+				BSP_LCD_DrawPixel(x+1,y+1,couleurmorte);
+			}
+		}
+	}
+	BSP_LCD_SetTextColor(couleur_demarrer);
+	BSP_LCD_FillRect(400,0,79,60);
+	BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+	BSP_LCD_DisplayStringAt(0,0, (uint8_t *)"START", RIGHT_MODE);
+}
+
+
+
+
+
+
+void Tabsomme(GRILLE G, GRILLE Gsomme) //réalisation du tableau des sommes a partir du tableau des états
+{	
+	int l;
+	int h;
+	for (l=1; l<LONGUEUR; l++)
+	{
+		for (h=1; h<HAUTEUR; h++)
+		{	
+			if (l<LONGUEUR && l>0 && h<HAUTEUR && h>0)
+			{
+				Gsomme[l][h]=SommeADJcorps(G,l,h);
+			}
+			else if (((l==0)&&(h==HAUTEUR||h==0))||((l==LONGUEUR)&&(h==HAUTEUR||h==0)))
+			{
+				Gsomme[l][h]=SommeADJcoins(G,l,h);
+			}
+			else if ((l==0 && (h!=0 && h!=HAUTEUR))||(l==LONGUEUR && (h!=0 && h!=HAUTEUR)))
+			{
+				Gsomme[l][h]=SommeADJcoteslat(G,l,h);
+			}
+			else if ((h==0 && (l!=0 && l!=LONGUEUR))||(h==HAUTEUR && (l!=0 && l!=LONGUEUR)))
+			{
+				Gsomme[l][h]=SommeADJcoteslon(G,l,h);
+			}
+				
+			
+		}
+	}
+}
+			
+			
+int SommeADJcorps(GRILLE G, int i, int h) // sous-fonction de Tabsomme qui gère les cases au centre du tableau (sans les cotés et les coins)
+{	
+	int s=0;
+	s+=(G[i+1][h] + G[i-1][h]);
+	s+=(G[i-1][h-1] + G[i][h-1] + G[i+1][h-1]);
+	s+=(G[i-1][h+1] + G[i][h+1] + G[i+1][h+1]);
+	return s;
+}
+
+int SommeADJcoteslat(GRILLE G,int i, int h) // sous-fonction de Tabsomme qui gère les cotés latéraux du tableau
+{	
+	if (i==0)
+		{
+		int s=0;
+		s+=(G[i][h+1] + G[i][h-1]);
+		s+=(G[i+1][h+1] + G[i+1][h-1] + G[i+1][h]);
+		s+=(G[LONGUEUR][h+1] + G[LONGUEUR][h-1] + G[LONGUEUR][h]);
+		return s; 
+	}
+	if (i==LONGUEUR)
+		{
+		int s=0;
+		s+=(G[i][h+1] + G[i][h-1]);
+		s+=(G[i-1][h+1] + G[i-1][h-1] + G[i-1][h]);
+		s+=(G[0][h+1] + G[0][h-1] + G[0][h]);
+		return s;
+	}
+	return 0;
+}
+
+int SommeADJcoteslon(GRILLE G,int i, int h)// sous-fonction de Tabsomme qui gère les cotés en longueur du tableau
+{	
+	if (h==0)
+		{
+		int s=0;
+		s+=(G[i+1][h] + G[i-1][h]);
+		s+=(G[i-1][h+1] + G[i][h+1] + G[i+1][h+1]);
+		s+=(G[i-1][HAUTEUR] + G[i][HAUTEUR] + G[i+1][HAUTEUR]);
+		return s; 
+	}
+	if (h==HAUTEUR)
+		{
+		int s=0;
+		s+=(G[i+1][h] + G[i-1][h]);
+		s+=(G[i-1][h+1] + G[i][h+1] + G[i+1][h+1]);
+		s+=(G[i-1][0] + G[i][HAUTEUR] + G[i+1][HAUTEUR]);
+		return s;
+	}
+	return 0;
+}
+	
+
+int SommeADJcoins(GRILLE G, int i, int h) // sous-fonction de Tabsomme qui gère les coins du tableaux
+{
+	int s=0;
+	if (i==0)
+		{
+		if (h==0) //coin sup gauche
+			{
+			s+=(G[LONGUEUR][HAUTEUR]);
+			s+=(G[1][0] + G[1][1] + G[0][1]);
+			s+=(G[LONGUEUR][0] + G[LONGUEUR][1]);
+			s+=(G[0][HAUTEUR] + G[1][HAUTEUR]);
+			return s;
+		}
+		else if (h==HAUTEUR) //coin inf gauche
+			{
+			s+=(G[LONGUEUR][0]);
+			s+=(G[0][HAUTEUR - 1] + G[1][HAUTEUR - 1] + G[1][HAUTEUR]);
+			s+=(G[LONGUEUR][HAUTEUR -1] + G[LONGUEUR][HAUTEUR]);
+			s+=(G[0][0] + G[1][0]);
+			return s;
+		}
+	}
+	else if (i==LONGUEUR)
+		{
+		if (h==0) //coin sup droit
+			{
+			s+=(G[0][HAUTEUR]);
+			s+=(G[LONGUEUR - 1][0] + G[LONGUEUR - 1][0] + G[LONGUEUR - 1][1]);
+			s+=(G[LONGUEUR][HAUTEUR] + G[LONGUEUR-1][HAUTEUR]);
+			s+=(G[0][0] + G[0][1]);
+			return s;
+		}
+		else if (h==HAUTEUR) //coin inf droit
+			{
+			s+=(G[0][0]);
+			s+=(G[LONGUEUR - 1][HAUTEUR] + G[LONGUEUR - 1][HAUTEUR - 1] + G[LONGUEUR][HAUTEUR - 1]);
+			s+=(G[LONGUEUR][0] + G[LONGUEUR - 1][0]);
+			s+=(G[0][HAUTEUR] + G[0][HAUTEUR - 1]);
+			return s;
+		}
+	}
+	return 0;
+}
+
+
+
+void partie(GRILLE G,GRILLE Gsomme){
+	int stop=0;
+	while(stop==0){
+		Tabsomme(G,Gsomme);
+		Changementetat(G,Gsomme);
+		Affichagepxl2(G);
+		if(TS_State.touchDetected != 0){
+			if (TS_State.touchX[0]>Gauche_bouton_demarrer && TS_State.touchY[0]<Bas_bouton_demarrer){
+				stop=1;
+			}
+		}
+		HAL_Delay(TEMPS_TOUR);
+	}
+}
+
+
+
+
+int fin_de_partie(GRILLE G,GRILLE Gsomme){
+	int rejouer=0;
+	int continuer=0;
+	BSP_LCD_SetTextColor(couleur_stop);
+	BSP_LCD_FillRect(400,0,79,60);
+	BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+	BSP_LCD_DisplayStringAt(0,0, (uint8_t *)"NEW TRY", RIGHT_MODE);
+	BSP_LCD_SetTextColor(couleur_demarrer);
+	BSP_LCD_FillRect(0,0,79,60);
+	BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+	BSP_LCD_DisplayStringAt(0,0, (uint8_t *)"CONTINUE", LEFT_MODE);
+	while(rejouer==0||continuer==0){
+		if(TS_State.touchDetected!=0){
+			if (TS_State.touchX[0]>Gauche_bouton_demarrer && TS_State.touchY[0]<Bas_bouton_demarrer){
+				rejouer=1;
+			}
+			else if (TS_State.touchX[0]<Droit_bouton_continuer && TS_State.touchY[0]<Bas_bouton_demarrer){
+				continuer=1;
+			}
+		}
+	}
+	if (continuer==1){
+		partie(G,Gsomme);
+		fin_de_partie(G,Gsomme);
+	}
+	return rejouer;
+}
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/prog_util/header.h	Wed Nov 18 08:07:27 2020 +0000
@@ -0,0 +1,58 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stm32746g_discovery_ts.h>
+#include <stm32746g_discovery_lcd.h>
+
+
+#define LONGUEUR 238  //sur la grille des états
+#define HAUTEUR 134 
+#define TEMPS_TOUR 100
+ 
+typedef char CASE;
+typedef CASE GRILLE[LONGUEUR+1][HAUTEUR+1];
+
+// limite du bouton "démarrer"
+#define Gauche_bouton_demarrer 400
+#define Bas_bouton_demarrer 60
+#define couleur_stop LCD_COLOR_GREEN
+#define couleur_demarrer LCD_COLOR_RED
+#define Droit_bouton_continuer 79
+
+// règles
+#define CVA_VIVANT 3//les test sont fait en intervalle ouvert (=> =<)
+#define CVA_MORT 2
+
+
+#define couleurvivante LCD_COLOR_WHITE
+#define couleurmorte LCD_COLOR_BLACK 
+//Fonctions du JDLV
+
+void Tabsomme(GRILLE G, GRILLE Gsomme);
+
+int SommeADJcorps(GRILLE G, int i, int h);
+ 
+int SommeADJcoteslat(GRILLE G,int i, int h);
+
+int SommeADJcoins(GRILLE G, int i, int h);
+ 
+int SommeADJcoteslon(GRILLE G,int i, int h);
+ 
+void Changementetat(GRILLE G, GRILLE Gsomme);
+ 
+void Affichagepxl2(GRILLE G);
+
+void Affichagepxl2_debut(GRILLE G);
+
+void partie(GRILLE G,GRILLE Gsomme);
+
+int fin_de_partie(GRILLE G,GRILLE Gsomme);
+
+void init_cellules(GRILLE G);
+
+
+
+
+
+
+