From patchwork Thu Jun 16 20:29:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1989 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 23C0C23F3F for ; Thu, 16 Jun 2011 20:31:45 +0000 (UTC) Received: from mail-vx0-f180.google.com (mail-vx0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id E666BA18585 for ; Thu, 16 Jun 2011 20:31:44 +0000 (UTC) Received: by mail-vx0-f180.google.com with SMTP id 12so2092646vxk.11 for ; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) Received: by 10.52.162.72 with SMTP id xy8mr1940876vdb.87.1308256304726; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs211202vdc; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) Received: by 10.216.0.206 with SMTP id 56mr1351026web.112.1308256302146; Thu, 16 Jun 2011 13:31:42 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by mx.google.com with ESMTP id y61si5065537weq.84.2011.06.16.13.31.41; Thu, 16 Jun 2011 13:31:42 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.130 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.130; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.130 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.134.76.78]) by mwinf5d16 with ME id wkXf1g0031hMfSL03kXhJR; Thu, 16 Jun 2011 22:31:41 +0200 From: Daniel Lezcano To: patches@linaro.org Subject: [PATCH 05/28] compute next and previous window with modulo arithmetic Date: Thu, 16 Jun 2011 22:29:34 +0200 Message-Id: <1308256197-29155-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308256197-29155-1-git-send-email-daniel.lezcano@linaro.org> References: <1308256197-29155-1-git-send-email-daniel.lezcano@linaro.org> Signed-off-by: Daniel Lezcano --- powerdebug.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/powerdebug.c b/powerdebug.c index dd4fe91..5fe07de 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -15,6 +15,7 @@ #include #include +#include #include "regulator.h" #include "display.h" #include "clocks.h" @@ -164,17 +165,16 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, if (keystroke == EOF) exit(0); - if (keystroke == KEY_RIGHT || keystroke == '\t') + if (keystroke == KEY_RIGHT || keystroke == '\t') { options->selectedwindow++; + options->selectedwindow %= TOTAL_FEATURE_WINS; + } - if (keystroke == KEY_LEFT || keystroke == KEY_BTAB) + if (keystroke == KEY_LEFT || keystroke == KEY_BTAB) { options->selectedwindow--; - - if (options->selectedwindow >= TOTAL_FEATURE_WINS) - options->selectedwindow = 0; - - if (options->selectedwindow < 0) - options->selectedwindow = TOTAL_FEATURE_WINS - 1; + if (options->selectedwindow < 0) + options->selectedwindow = TOTAL_FEATURE_WINS - 1; + } if (options->selectedwindow == CLOCK) { if (keystroke == KEY_DOWN)