Просмотр исходного кода

v1.0.1: update to work with new mutex API

BlueChip 2 лет назад
Родитель
Сommit
8ff921b4f8
3 измененных файлов с 15 добавлено и 11 удалено
  1. 12 11
      wii_anal.c
  2. 2 0
      wii_anal.h
  3. 1 0
      wii_anal_ver.h

+ 12 - 11
wii_anal.c

@@ -86,6 +86,8 @@ void  showVer (Canvas* const canvas)
 	show(canvas,  4,59, VER_MAJ,    SHOW_SET_BLK);
 	show(canvas,  4,59, VER_MAJ,    SHOW_SET_BLK);
 	canvas_draw_frame(canvas, 8,62, 2,2);
 	canvas_draw_frame(canvas, 8,62, 2,2);
 	show(canvas, 11,59, VER_MIN,   SHOW_SET_BLK);
 	show(canvas, 11,59, VER_MIN,   SHOW_SET_BLK);
+	canvas_draw_frame(canvas, 15,62, 2,2);
+	show(canvas, 18,59, VER_SUB,   SHOW_SET_BLK);
 }
 }
 
 
 //+============================================================================
 //+============================================================================
@@ -102,10 +104,10 @@ void  cbDraw (Canvas* const canvas,  void* ctx)
 	furi_assert(canvas);
 	furi_assert(canvas);
 	furi_assert(ctx);
 	furi_assert(ctx);
 
 
-	state_t*  state = NULL;
+	state_t*  state = ctx;
 
 
 	// Try to acquire the mutex for the plugin state variables, timeout = 25mS
 	// Try to acquire the mutex for the plugin state variables, timeout = 25mS
-	if ( !(state = (state_t*)acquire_mutex((ValueMutex*)ctx, 25)) )  return ;
+	if (furi_mutex_acquire(state->mutex, 25) != FuriStatusOk)  return ;
 
 
 	switch (state->scene) {
 	switch (state->scene) {
 		//---------------------------------------------------------------------
 		//---------------------------------------------------------------------
@@ -190,7 +192,7 @@ void  cbDraw (Canvas* const canvas,  void* ctx)
 	}
 	}
 
 
 	// Release    the  mutex
 	// Release    the  mutex
-	release_mutex((ValueMutex*)ctx, state);
+	furi_mutex_release(state->mutex);
 
 
 	LEAVE;
 	LEAVE;
 	return;
 	return;
@@ -320,7 +322,6 @@ int32_t  wii_ec_anal (void)
 	Gui*               gui     = NULL;
 	Gui*               gui     = NULL;
 	ViewPort*          vpp     = NULL;
 	ViewPort*          vpp     = NULL;
 	state_t*           state   = NULL;
 	state_t*           state   = NULL;
-	ValueMutex         mutex   = {0};
 	FuriMessageQueue*  queue   = NULL;
 	FuriMessageQueue*  queue   = NULL;
 	const uint32_t     queueSz = 20;       // maximum messages in queue
 	const uint32_t     queueSz = 20;       // maximum messages in queue
 	uint32_t           tmo     = (3.5f *1000);  // timeout splash screen after N seconds
 	uint32_t           tmo     = (3.5f *1000);  // timeout splash screen after N seconds
@@ -358,7 +359,7 @@ int32_t  wii_ec_anal (void)
 		goto bail;
 		goto bail;
 	}
 	}
 	// 5. Create a mutex for (reading/writing) the plugin state variables
 	// 5. Create a mutex for (reading/writing) the plugin state variables
-	if (!init_mutex(&mutex, state, sizeof(state))) {
+	if ( !(state->mutex = furi_mutex_alloc(FuriMutexTypeNormal)) ) {
 		ERROR(wii_errs[(error = ERR_NO_MUTEX)]);
 		ERROR(wii_errs[(error = ERR_NO_MUTEX)]);
 		goto bail;
 		goto bail;
 	}
 	}
@@ -372,7 +373,7 @@ int32_t  wii_ec_anal (void)
 	// 7a. Register a callback for input events
 	// 7a. Register a callback for input events
 	view_port_input_callback_set(vpp, cbInput, queue);
 	view_port_input_callback_set(vpp, cbInput, queue);
 	// 7b. Register a callback for draw events
 	// 7b. Register a callback for draw events
-	view_port_draw_callback_set(vpp, cbDraw, &mutex);
+	view_port_draw_callback_set(vpp, cbDraw, state);
 
 
 	// ===== Start GUI Interface =====
 	// ===== Start GUI Interface =====
 	// 8. Attach the viewport to the GUI
 	// 8. Attach the viewport to the GUI
@@ -432,7 +433,7 @@ int32_t  wii_ec_anal (void)
 		// Read successful
 		// Read successful
 
 
 		// *** Try to lock the plugin state variables ***
 		// *** Try to lock the plugin state variables ***
-		if ( !(state = (state_t*)acquire_mutex_block(&mutex)) ) {
+		if (furi_mutex_acquire(state->mutex, FuriWaitForever) != FuriStatusOk) {
 			ERROR(wii_errs[(error = ERR_MUTEX_BLOCK)]);
 			ERROR(wii_errs[(error = ERR_MUTEX_BLOCK)]);
 			goto bail;
 			goto bail;
 		}
 		}
@@ -473,7 +474,7 @@ int32_t  wii_ec_anal (void)
 		if (redraw)  view_port_update(vpp) ;
 		if (redraw)  view_port_update(vpp) ;
 
 
 		// *** Try to release the plugin state variables ***
 		// *** Try to release the plugin state variables ***
-		if ( !release_mutex(&mutex, state) ) {
+		if (furi_mutex_release(state->mutex) != FuriStatusOk) {
 			ERROR(wii_errs[(error = ERR_MUTEX_RELEASE)]);
 			ERROR(wii_errs[(error = ERR_MUTEX_RELEASE)]);
 			goto bail;
 			goto bail;
 		}
 		}
@@ -511,9 +512,9 @@ bail:
 	}
 	}
 
 
 	// 5. Free the mutex
 	// 5. Free the mutex
-	if (mutex.mutex) {
-		delete_mutex(&mutex);
-		mutex.mutex = NULL;
+	if (state->mutex) {
+		furi_mutex_free(state->mutex);
+		state->mutex = NULL;
 	}
 	}
 
 
 	// 4. Free up state pointer(s)
 	// 4. Free up state pointer(s)

+ 2 - 0
wii_anal.h

@@ -63,6 +63,8 @@ eventMsg_t;
 //
 //
 typedef 
 typedef 
 	struct state {
 	struct state {
+		FuriMutex*        mutex;      // mutex for using this struct
+
 		bool              run;        // true : plugin is running
 		bool              run;        // true : plugin is running
 
 
 		bool              timerEn;    // controller scanning enabled
 		bool              timerEn;    // controller scanning enabled

+ 1 - 0
wii_anal_ver.h

@@ -5,5 +5,6 @@
 
 
 #define  VER_MAJ  &img_3x5_1
 #define  VER_MAJ  &img_3x5_1
 #define  VER_MIN  &img_3x5_0
 #define  VER_MIN  &img_3x5_0
+#define  VER_SUB  &img_3x5_1
 
 
 #endif //WII_ANAL_VER_H_
 #endif //WII_ANAL_VER_H_